@@ -216,7 +216,6 @@ impl crate::StateIndexerDbManager for crate::PostgresDBManager {
216
216
shard_id : near_primitives:: types:: ShardId ,
217
217
state_changes : Vec < near_primitives:: views:: StateChangeWithCauseView > ,
218
218
block_height : u64 ,
219
- block_hash : near_primitives:: hash:: CryptoHash ,
220
219
) -> anyhow:: Result < ( ) > {
221
220
crate :: metrics:: SHARD_DATABASE_WRITE_QUERIES
222
221
. with_label_values ( & [
@@ -225,8 +224,9 @@ impl crate::StateIndexerDbManager for crate::PostgresDBManager {
225
224
"state_changes_data" ,
226
225
] )
227
226
. inc ( ) ;
227
+ let range_id = configuration:: utils:: get_data_range_id ( & block_height) . await ?;
228
228
let mut query_builder: sqlx:: QueryBuilder < sqlx:: Postgres > = sqlx:: QueryBuilder :: new (
229
- "INSERT INTO state_changes_data (account_id, block_height, block_hash, data_key, data_value) " ,
229
+ format ! ( "INSERT INTO state_changes_data_{range_id} (account_id, block_height, data_key, data_value) " ) ,
230
230
) ;
231
231
query_builder. push_values ( state_changes. iter ( ) , |mut values, state_change| {
232
232
match & state_change. value {
@@ -240,7 +240,6 @@ impl crate::StateIndexerDbManager for crate::PostgresDBManager {
240
240
values
241
241
. push_bind ( account_id. to_string ( ) )
242
242
. push_bind ( bigdecimal:: BigDecimal :: from ( block_height) )
243
- . push_bind ( block_hash. to_string ( ) )
244
243
. push_bind ( hex:: encode ( data_key) . to_string ( ) )
245
244
. push_bind ( data_value) ;
246
245
}
@@ -250,7 +249,6 @@ impl crate::StateIndexerDbManager for crate::PostgresDBManager {
250
249
values
251
250
. push_bind ( account_id. to_string ( ) )
252
251
. push_bind ( bigdecimal:: BigDecimal :: from ( block_height) )
253
- . push_bind ( block_hash. to_string ( ) )
254
252
. push_bind ( hex:: encode ( data_key) . to_string ( ) )
255
253
. push_bind ( data_value) ;
256
254
}
@@ -273,7 +271,6 @@ impl crate::StateIndexerDbManager for crate::PostgresDBManager {
273
271
shard_id : near_primitives:: types:: ShardId ,
274
272
state_changes : Vec < near_primitives:: views:: StateChangeWithCauseView > ,
275
273
block_height : u64 ,
276
- block_hash : near_primitives:: hash:: CryptoHash ,
277
274
) -> anyhow:: Result < ( ) > {
278
275
crate :: metrics:: SHARD_DATABASE_WRITE_QUERIES
279
276
. with_label_values ( & [
@@ -282,8 +279,9 @@ impl crate::StateIndexerDbManager for crate::PostgresDBManager {
282
279
"state_changes_access_key" ,
283
280
] )
284
281
. inc ( ) ;
282
+ let range_id = configuration:: utils:: get_data_range_id ( & block_height) . await ?;
285
283
let mut query_builder: sqlx:: QueryBuilder < sqlx:: Postgres > = sqlx:: QueryBuilder :: new (
286
- "INSERT INTO state_changes_access_key (account_id, block_height, block_hash, data_key, data_value) " ,
284
+ format ! ( "INSERT INTO state_changes_access_key_{range_id} (account_id, block_height, data_key, data_value) " ) ,
287
285
) ;
288
286
query_builder. push_values ( state_changes. iter ( ) , |mut values, state_change| {
289
287
match & state_change. value {
@@ -299,7 +297,6 @@ impl crate::StateIndexerDbManager for crate::PostgresDBManager {
299
297
values
300
298
. push_bind ( account_id. to_string ( ) )
301
299
. push_bind ( bigdecimal:: BigDecimal :: from ( block_height) )
302
- . push_bind ( block_hash. to_string ( ) )
303
300
. push_bind ( hex:: encode ( data_key) . to_string ( ) )
304
301
. push_bind ( data_value) ;
305
302
}
@@ -313,7 +310,6 @@ impl crate::StateIndexerDbManager for crate::PostgresDBManager {
313
310
values
314
311
. push_bind ( account_id. to_string ( ) )
315
312
. push_bind ( bigdecimal:: BigDecimal :: from ( block_height) )
316
- . push_bind ( block_hash. to_string ( ) )
317
313
. push_bind ( hex:: encode ( data_key) . to_string ( ) )
318
314
. push_bind ( data_value) ;
319
315
}
@@ -336,7 +332,6 @@ impl crate::StateIndexerDbManager for crate::PostgresDBManager {
336
332
shard_id : near_primitives:: types:: ShardId ,
337
333
state_changes : Vec < near_primitives:: views:: StateChangeWithCauseView > ,
338
334
block_height : u64 ,
339
- block_hash : near_primitives:: hash:: CryptoHash ,
340
335
) -> anyhow:: Result < ( ) > {
341
336
crate :: metrics:: SHARD_DATABASE_WRITE_QUERIES
342
337
. with_label_values ( & [
@@ -345,8 +340,9 @@ impl crate::StateIndexerDbManager for crate::PostgresDBManager {
345
340
"state_changes_contract" ,
346
341
] )
347
342
. inc ( ) ;
343
+ let range_id = configuration:: utils:: get_data_range_id ( & block_height) . await ?;
348
344
let mut query_builder: sqlx:: QueryBuilder < sqlx:: Postgres > = sqlx:: QueryBuilder :: new (
349
- "INSERT INTO state_changes_contract (account_id, block_height, block_hash, data_value) " ,
345
+ format ! ( "INSERT INTO state_changes_contract_{range_id} (account_id, block_height, data_value) " ) ,
350
346
) ;
351
347
query_builder. push_values ( state_changes. iter ( ) , |mut values, state_change| {
352
348
match & state_change. value {
@@ -358,7 +354,6 @@ impl crate::StateIndexerDbManager for crate::PostgresDBManager {
358
354
values
359
355
. push_bind ( account_id. to_string ( ) )
360
356
. push_bind ( bigdecimal:: BigDecimal :: from ( block_height) )
361
- . push_bind ( block_hash. to_string ( ) )
362
357
. push_bind ( data_value) ;
363
358
}
364
359
near_primitives:: views:: StateChangeValueView :: ContractCodeDeletion {
@@ -368,7 +363,6 @@ impl crate::StateIndexerDbManager for crate::PostgresDBManager {
368
363
values
369
364
. push_bind ( account_id. to_string ( ) )
370
365
. push_bind ( bigdecimal:: BigDecimal :: from ( block_height) )
371
- . push_bind ( block_hash. to_string ( ) )
372
366
. push_bind ( data_value) ;
373
367
}
374
368
_ => { }
@@ -390,7 +384,6 @@ impl crate::StateIndexerDbManager for crate::PostgresDBManager {
390
384
shard_id : near_primitives:: types:: ShardId ,
391
385
state_changes : Vec < near_primitives:: views:: StateChangeWithCauseView > ,
392
386
block_height : u64 ,
393
- block_hash : near_primitives:: hash:: CryptoHash ,
394
387
) -> anyhow:: Result < ( ) > {
395
388
crate :: metrics:: SHARD_DATABASE_WRITE_QUERIES
396
389
. with_label_values ( & [
@@ -399,8 +392,9 @@ impl crate::StateIndexerDbManager for crate::PostgresDBManager {
399
392
"state_changes_account" ,
400
393
] )
401
394
. inc ( ) ;
395
+ let range_id = configuration:: utils:: get_data_range_id ( & block_height) . await ?;
402
396
let mut query_builder: sqlx:: QueryBuilder < sqlx:: Postgres > = sqlx:: QueryBuilder :: new (
403
- "INSERT INTO state_changes_account (account_id, block_height, block_hash, data_value) " ,
397
+ format ! ( "INSERT INTO state_changes_account_{range_id} (account_id, block_height, data_value) " ) ,
404
398
) ;
405
399
query_builder. push_values ( state_changes. iter ( ) , |mut values, state_change| {
406
400
match & state_change. value {
@@ -414,15 +408,13 @@ impl crate::StateIndexerDbManager for crate::PostgresDBManager {
414
408
values
415
409
. push_bind ( account_id. to_string ( ) )
416
410
. push_bind ( bigdecimal:: BigDecimal :: from ( block_height) )
417
- . push_bind ( block_hash. to_string ( ) )
418
411
. push_bind ( data_value) ;
419
412
}
420
413
near_primitives:: views:: StateChangeValueView :: AccountDeletion { account_id } => {
421
414
let data_value: Option < & [ u8 ] > = None ;
422
415
values
423
416
. push_bind ( account_id. to_string ( ) )
424
417
. push_bind ( bigdecimal:: BigDecimal :: from ( block_height) )
425
- . push_bind ( block_hash. to_string ( ) )
426
418
. push_bind ( data_value) ;
427
419
}
428
420
_ => { }
0 commit comments