@@ -37,14 +37,6 @@ namespace silkworm::db {
3737
3838using namespace silkworm ::snapshots;
3939
40- struct FreezerCommand : public DataMigrationCommand {
41- BlockNumRange range;
42-
43- explicit FreezerCommand (BlockNumRange range1)
44- : range(std::move(range1)) {}
45- ~FreezerCommand () override = default ;
46- };
47-
4840struct FreezerResult : public DataMigrationResult {
4941 SnapshotBundle bundle;
5042
@@ -63,6 +55,12 @@ static BlockNum get_first_stored_header_num(ROTxn& txn) {
6355 return num_opt.value_or (0 );
6456}
6557
58+ static std::optional<uint64_t > get_next_base_txn_id (BlockNum number) {
59+ auto body = DataModel::read_body_for_storage_from_snapshot (number);
60+ if (!body) return std::nullopt ;
61+ return body->base_txn_id + body->txn_count ;
62+ }
63+
6664std::unique_ptr<DataMigrationCommand> Freezer::next_command () {
6765 BlockNum last_frozen = snapshots_.max_block_available ();
6866 BlockNum start = (last_frozen > 0 ) ? last_frozen + 1 : 0 ;
@@ -73,8 +71,15 @@ std::unique_ptr<DataMigrationCommand> Freezer::next_command() {
7371 return get_tip_num (db_tx);
7472 }();
7573
74+ uint64_t base_txn_id = [last_frozen]() -> uint64_t {
75+ if (last_frozen == 0 ) return 0 ;
76+ auto id = get_next_base_txn_id (last_frozen);
77+ assert (id.has_value ());
78+ return *id;
79+ }();
80+
7681 if (end + kFullImmutabilityThreshold <= tip) {
77- return std::make_unique<FreezerCommand>(FreezerCommand{{start, end}});
82+ return std::make_unique<FreezerCommand>(FreezerCommand{{start, end}, base_txn_id });
7883 }
7984 return {};
8085}
@@ -108,7 +113,7 @@ std::shared_ptr<DataMigrationResult> Freezer::migrate(std::unique_ptr<DataMigrat
108113 {
109114 auto db_tx = db_access_.start_ro_tx ();
110115 auto & freezer = get_snapshot_freezer (path.type ());
111- freezer.copy (db_tx, range , file_writer);
116+ freezer.copy (db_tx, freezer_command , file_writer);
112117 }
113118 SnapshotFileWriter::flush (std::move (file_writer));
114119 }
0 commit comments