@@ -221,34 +221,24 @@ std::vector<SilkwormChainSnapshot> collect_all_snapshots(const SnapshotRepositor
221221 return snapshot_sequence;
222222}
223223
224- std::tuple<int , BlockNum, int > execute (SilkwormHandle handle, ExecuteBlocksSettings settings, ::mdbx::env env, MDBX_txn* txn, ChainId chain_id, BlockNum start_block) {
225- const auto max_block{settings.max_block };
226- const auto batch_size{settings.batch_size };
227- const auto write_change_sets{settings.write_change_sets };
228- const auto write_receipts{settings.write_receipts };
229- const auto write_call_traces{settings.write_call_traces };
230- BlockNum last_executed_block{0 };
231- int mdbx_error_code{0 };
232- const uint64_t count{max_block - start_block + 1 };
233- SILK_DEBUG << " Execute blocks start_block=" << start_block << " end_block=" << max_block << " count=" << count << " batch_size=" << batch_size << " start" ;
234- const int status_code = silkworm_execute_blocks (
235- handle, env, txn, chain_id,
236- start_block, max_block, batch_size,
237- write_change_sets, write_receipts, write_call_traces,
238- &last_executed_block, &mdbx_error_code);
239- SILK_DEBUG << " Execute blocks start_block=" << start_block << " end_block=" << max_block << " count=" << count << " batch_size=" << batch_size << " done" ;
240- return {status_code, last_executed_block, mdbx_error_code};
241- }
242-
243224int execute_with_internal_txn (SilkwormHandle handle, ExecuteBlocksSettings settings, ::mdbx::env& env) {
244225 db::ROTxnManaged ro_txn{env};
245226 const auto chain_config{db::read_chain_config (ro_txn)};
246227 ensure (chain_config.has_value (), " no chain configuration in database" );
247228 const auto chain_id{chain_config->chain_id };
248229 ro_txn.abort ();
249230
250- const auto start_block{settings.start_block };
251- const auto [status_code, last_executed_block, mdbx_error_code] = execute (handle, settings, env, nullptr , chain_id, start_block);
231+ BlockNum last_executed_block{0 };
232+ int mdbx_error_code{0 };
233+ const uint64_t count{settings.max_block - settings.start_block + 1 };
234+ SILK_DEBUG << " Execute blocks start_block=" << settings.start_block << " end_block=" << settings.max_block << " count=" << count << " batch_size=" << settings.batch_size << " start" ;
235+ const int status_code = silkworm_execute_blocks_perpetual (
236+ handle, env, chain_id,
237+ settings.start_block , settings.max_block , settings.batch_size ,
238+ settings.write_change_sets , settings.write_receipts , settings.write_call_traces ,
239+ &last_executed_block, &mdbx_error_code);
240+ SILK_DEBUG << " Execute blocks start_block=" << settings.start_block << " end_block=" << settings.max_block << " count=" << count << " batch_size=" << settings.batch_size << " done" ;
241+
252242 if (status_code != SILKWORM_OK) {
253243 SILK_ERROR << " execute_with_internal_txn failed [code=" << std::to_string (status_code)
254244 << (status_code == SILKWORM_MDBX_ERROR ? " mdbx_error_code=" + std::to_string (mdbx_error_code) : " " )
@@ -270,7 +260,14 @@ int execute_with_external_txn(SilkwormHandle handle, ExecuteBlocksSettings setti
270260 auto start_block{settings.start_block };
271261 const auto max_block{settings.max_block };
272262 while (start_block <= max_block) {
273- const auto [status_code, last_executed_block, mdbx_error_code] = execute (handle, settings, env, *rw_txn, chain_id, start_block);
263+ BlockNum last_executed_block{0 };
264+ int mdbx_error_code{0 };
265+ const int status_code = silkworm_execute_blocks_ephemeral (
266+ handle, *rw_txn, chain_id,
267+ settings.start_block , settings.max_block , settings.batch_size ,
268+ settings.write_change_sets , settings.write_receipts , settings.write_call_traces ,
269+ &last_executed_block, &mdbx_error_code);
270+
274271 if (status_code != SILKWORM_OK) {
275272 SILK_ERROR << " execute_with_external_txn failed [code=" << std::to_string (status_code)
276273 << (status_code == SILKWORM_MDBX_ERROR ? " mdbx_error_code=" + std::to_string (mdbx_error_code) : " " )
0 commit comments