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