@@ -41,11 +41,13 @@ static SnapshotPath parse_snapshot_path(const char* file_path) {
41
41
static void build_inverted_index_bundle_data (
42
42
const SilkwormInvertedIndexSnapshot& snapshot,
43
43
const Schema::EntityDef& entity_def,
44
+ const datastore::StepToTimestampConverter& step_converter,
44
45
SnapshotBundleEntityData& data) {
45
46
data.kv_segments .emplace (
46
47
Schema::kInvIdxKVSegmentName ,
47
48
segment::KVSegmentFileReader{
48
49
parse_snapshot_path (snapshot.segment .file_path ),
50
+ step_converter,
49
51
entity_def.kv_segment (Schema::kInvIdxKVSegmentName ).compression_kind (),
50
52
make_region (snapshot.segment ),
51
53
});
@@ -59,21 +61,24 @@ static void build_inverted_index_bundle_data(
59
61
60
62
static snapshots::SnapshotBundleEntityData build_inverted_index_bundle_data (
61
63
const SilkwormInvertedIndexSnapshot& snapshot,
62
- const Schema::EntityDef& entity_def) {
64
+ const Schema::EntityDef& entity_def,
65
+ const datastore::StepToTimestampConverter& step_converter) {
63
66
SnapshotBundleEntityData data;
64
- build_inverted_index_bundle_data (snapshot, entity_def, data);
67
+ build_inverted_index_bundle_data (snapshot, entity_def, step_converter, data);
65
68
return data;
66
69
}
67
70
68
71
static snapshots::SnapshotBundleEntityData build_domain_bundle_data (
69
72
const SilkwormDomainSnapshot& snapshot,
70
73
const Schema::EntityDef& entity_def,
74
+ const datastore::StepToTimestampConverter& step_converter,
71
75
uint32_t index_salt) {
72
76
SnapshotBundleEntityData data;
73
77
data.kv_segments .emplace (
74
78
Schema::kDomainKVSegmentName ,
75
79
segment::KVSegmentFileReader{
76
80
parse_snapshot_path (snapshot.segment .file_path ),
81
+ step_converter,
77
82
entity_def.kv_segment (Schema::kDomainKVSegmentName ).compression_kind (),
78
83
make_region (snapshot.segment ),
79
84
});
@@ -102,12 +107,14 @@ static snapshots::SnapshotBundleEntityData build_domain_bundle_data(
102
107
103
108
static snapshots::SnapshotBundleEntityData build_history_bundle_data (
104
109
const SilkwormHistorySnapshot& snapshot,
105
- const Schema::EntityDef& entity_def) {
110
+ const Schema::EntityDef& entity_def,
111
+ const datastore::StepToTimestampConverter& step_converter) {
106
112
SnapshotBundleEntityData data;
107
113
data.segments .emplace (
108
114
Schema::kHistorySegmentName ,
109
115
segment::SegmentFileReader{
110
116
parse_snapshot_path (snapshot.segment .file_path ),
117
+ step_converter,
111
118
make_region (snapshot.segment ),
112
119
});
113
120
data.accessor_indexes .emplace (
@@ -117,7 +124,7 @@ static snapshots::SnapshotBundleEntityData build_history_bundle_data(
117
124
make_region (snapshot.accessor_index ),
118
125
});
119
126
120
- build_inverted_index_bundle_data (snapshot.inverted_index , entity_def, data);
127
+ build_inverted_index_bundle_data (snapshot.inverted_index , entity_def, step_converter, data);
121
128
return data;
122
129
}
123
130
@@ -126,22 +133,24 @@ static snapshots::SnapshotBundle build_state_snapshot_bundle_latest(
126
133
const Schema::RepositoryDef& schema,
127
134
uint32_t salt) {
128
135
SnapshotBundleData bundle_data;
136
+ datastore::StepToTimestampConverter step_converter = schema.make_step_converter ();
137
+
129
138
bundle_data.entities .emplace (
130
139
db::state::kDomainNameAccounts ,
131
- build_domain_bundle_data (bundle->accounts , schema.domain (db::state::kDomainNameAccounts ), salt));
140
+ build_domain_bundle_data (bundle->accounts , schema.domain (db::state::kDomainNameAccounts ), step_converter, salt));
132
141
bundle_data.entities .emplace (
133
142
db::state::kDomainNameStorage ,
134
- build_domain_bundle_data (bundle->storage , schema.domain (db::state::kDomainNameStorage ), salt));
143
+ build_domain_bundle_data (bundle->storage , schema.domain (db::state::kDomainNameStorage ), step_converter, salt));
135
144
bundle_data.entities .emplace (
136
145
db::state::kDomainNameCode ,
137
- build_domain_bundle_data (bundle->code , schema.domain (db::state::kDomainNameCode ), salt));
146
+ build_domain_bundle_data (bundle->code , schema.domain (db::state::kDomainNameCode ), step_converter, salt));
138
147
// TODO(canepat): enable after fixing .kvi configuration with IndexList-like implementation
139
148
// bundle_data.entities.emplace(
140
149
// db::state::kDomainNameCommitment,
141
- // build_domain_bundle_data(bundle->commitment, schema.domain(db::state::kDomainNameCommitment), salt));
150
+ // build_domain_bundle_data(bundle->commitment, schema.domain(db::state::kDomainNameCommitment), step_converter, salt));
142
151
bundle_data.entities .emplace (
143
152
db::state::kDomainNameReceipts ,
144
- build_domain_bundle_data (bundle->receipts , schema.domain (db::state::kDomainNameReceipts ), salt));
153
+ build_domain_bundle_data (bundle->receipts , schema.domain (db::state::kDomainNameReceipts ), step_converter, salt));
145
154
146
155
return SnapshotBundle{
147
156
parse_snapshot_path (bundle->accounts .segment .file_path ).step_range (),
@@ -153,32 +162,33 @@ static snapshots::SnapshotBundle build_state_snapshot_bundle_historical(
153
162
const SilkwormStateSnapshotBundleHistorical* bundle,
154
163
const Schema::RepositoryDef& schema) {
155
164
SnapshotBundleData bundle_data;
165
+ datastore::StepToTimestampConverter step_converter = schema.make_step_converter ();
156
166
157
167
bundle_data.entities .emplace (
158
168
db::state::kDomainNameAccounts ,
159
- build_history_bundle_data (bundle->accounts , schema.history (db::state::kDomainNameAccounts )));
169
+ build_history_bundle_data (bundle->accounts , schema.history (db::state::kDomainNameAccounts ), step_converter ));
160
170
bundle_data.entities .emplace (
161
171
db::state::kDomainNameStorage ,
162
- build_history_bundle_data (bundle->storage , schema.history (db::state::kDomainNameStorage )));
172
+ build_history_bundle_data (bundle->storage , schema.history (db::state::kDomainNameStorage ), step_converter ));
163
173
bundle_data.entities .emplace (
164
174
db::state::kDomainNameCode ,
165
- build_history_bundle_data (bundle->code , schema.history (db::state::kDomainNameCode )));
175
+ build_history_bundle_data (bundle->code , schema.history (db::state::kDomainNameCode ), step_converter ));
166
176
bundle_data.entities .emplace (
167
177
db::state::kDomainNameReceipts ,
168
- build_history_bundle_data (bundle->receipts , schema.history (db::state::kDomainNameReceipts )));
178
+ build_history_bundle_data (bundle->receipts , schema.history (db::state::kDomainNameReceipts ), step_converter ));
169
179
170
180
bundle_data.entities .emplace (
171
181
db::state::kInvIdxNameLogAddress ,
172
- build_inverted_index_bundle_data (bundle->log_addresses , schema.inverted_index (db::state::kInvIdxNameLogAddress )));
182
+ build_inverted_index_bundle_data (bundle->log_addresses , schema.inverted_index (db::state::kInvIdxNameLogAddress ), step_converter ));
173
183
bundle_data.entities .emplace (
174
184
db::state::kInvIdxNameLogTopics ,
175
- build_inverted_index_bundle_data (bundle->log_topics , schema.inverted_index (db::state::kInvIdxNameLogTopics )));
185
+ build_inverted_index_bundle_data (bundle->log_topics , schema.inverted_index (db::state::kInvIdxNameLogTopics ), step_converter ));
176
186
bundle_data.entities .emplace (
177
187
db::state::kInvIdxNameTracesFrom ,
178
- build_inverted_index_bundle_data (bundle->traces_from , schema.inverted_index (db::state::kInvIdxNameTracesFrom )));
188
+ build_inverted_index_bundle_data (bundle->traces_from , schema.inverted_index (db::state::kInvIdxNameTracesFrom ), step_converter ));
179
189
bundle_data.entities .emplace (
180
190
db::state::kInvIdxNameTracesTo ,
181
- build_inverted_index_bundle_data (bundle->traces_to , schema.inverted_index (db::state::kInvIdxNameTracesTo )));
191
+ build_inverted_index_bundle_data (bundle->traces_to , schema.inverted_index (db::state::kInvIdxNameTracesTo ), step_converter ));
182
192
183
193
return SnapshotBundle{
184
194
parse_snapshot_path (bundle->accounts .segment .file_path ).step_range (),
@@ -278,13 +288,17 @@ SILKWORM_EXPORT int silkworm_build_recsplit_indexes(SilkwormHandle handle, struc
278
288
return SILKWORM_OK;
279
289
}
280
290
281
- static snapshots::SnapshotBundle build_blocks_snapshot_bundle (const SilkwormBlocksSnapshotBundle* bundle) {
291
+ static snapshots::SnapshotBundle build_blocks_snapshot_bundle (
292
+ const SilkwormBlocksSnapshotBundle* bundle,
293
+ const Schema::RepositoryDef& schema) {
282
294
snapshots::SnapshotBundleEntityData data;
295
+ datastore::StepToTimestampConverter step_converter = schema.make_step_converter ();
283
296
284
297
data.segments .emplace (
285
298
db::blocks::kHeaderSegmentName ,
286
299
snapshots::segment::SegmentFileReader{
287
300
parse_snapshot_path (bundle->headers .segment .file_path ),
301
+ step_converter,
288
302
make_region (bundle->headers .segment ),
289
303
});
290
304
data.accessor_indexes .emplace (
@@ -298,6 +312,7 @@ static snapshots::SnapshotBundle build_blocks_snapshot_bundle(const SilkwormBloc
298
312
db::blocks::kBodySegmentName ,
299
313
snapshots::segment::SegmentFileReader{
300
314
parse_snapshot_path (bundle->bodies .segment .file_path ),
315
+ step_converter,
301
316
make_region (bundle->bodies .segment ),
302
317
});
303
318
data.accessor_indexes .emplace (
@@ -311,6 +326,7 @@ static snapshots::SnapshotBundle build_blocks_snapshot_bundle(const SilkwormBloc
311
326
db::blocks::kTxnSegmentName ,
312
327
snapshots::segment::SegmentFileReader{
313
328
parse_snapshot_path (bundle->transactions .segment .file_path ),
329
+ step_converter,
314
330
make_region (bundle->transactions .segment ),
315
331
});
316
332
data.accessor_indexes .emplace (
@@ -348,7 +364,7 @@ SILKWORM_EXPORT int silkworm_add_blocks_snapshot_bundle(
348
364
349
365
auto & repository = *handle->blocks_repository ;
350
366
351
- repository.add_snapshot_bundle (build_blocks_snapshot_bundle (bundle));
367
+ repository.add_snapshot_bundle (build_blocks_snapshot_bundle (bundle, repository. schema () ));
352
368
return SILKWORM_OK;
353
369
} catch (const InvalidSnapshotPathException&) {
354
370
return SILKWORM_INVALID_PATH;
0 commit comments