@@ -6,8 +6,7 @@ use async_trait::async_trait;
6
6
7
7
use mithril_common:: crypto_helper:: MKTreeNode ;
8
8
use mithril_common:: entities:: {
9
- BlockHash , BlockNumber , BlockRange , CardanoTransaction , ChainPoint , ImmutableFileNumber ,
10
- SlotNumber , TransactionHash ,
9
+ BlockHash , BlockNumber , BlockRange , CardanoTransaction , ChainPoint , SlotNumber , TransactionHash ,
11
10
} ;
12
11
use mithril_common:: signable_builder:: BlockRangeRootRetriever ;
13
12
use mithril_common:: StdResult ;
@@ -68,14 +67,12 @@ impl CardanoTransactionRepository {
68
67
block_number : BlockNumber ,
69
68
slot_number : SlotNumber ,
70
69
block_hash : U ,
71
- immutable_file_number : ImmutableFileNumber ,
72
70
) -> StdResult < Option < CardanoTransactionRecord > > {
73
71
let query = InsertCardanoTransactionQuery :: insert_one ( & CardanoTransactionRecord {
74
72
transaction_hash : transaction_hash. into ( ) ,
75
73
block_number,
76
74
slot_number,
77
75
block_hash : block_hash. into ( ) ,
78
- immutable_file_number,
79
76
} ) ?;
80
77
81
78
self . connection_pool . connection ( ) ?. fetch_first ( query)
@@ -190,22 +187,6 @@ impl CardanoTransactionRepository {
190
187
. fetch_collect ( GetBlockRangeRootQuery :: all ( ) )
191
188
}
192
189
193
- /// Get the highest [ImmutableFileNumber] of the cardano transactions stored in the database.
194
- pub async fn get_transaction_highest_immutable_file_number (
195
- & self ,
196
- ) -> StdResult < Option < ImmutableFileNumber > > {
197
- let highest: Option < i64 > = self . connection_pool . connection ( ) ?. query_single_cell (
198
- "select max(immutable_file_number) as highest from cardano_tx;" ,
199
- & [ ] ,
200
- ) ?;
201
- highest
202
- . map ( u64:: try_from)
203
- . transpose ( )
204
- . with_context ( ||
205
- format ! ( "Integer field max(immutable_file_number) (value={highest:?}) is incompatible with u64 representation." )
206
- )
207
- }
208
-
209
190
/// Store the given transactions in the database.
210
191
///
211
192
/// The storage is done in chunks to avoid exceeding sqlite binding limitations.
@@ -354,7 +335,6 @@ mod tests {
354
335
block_number: 10 ,
355
336
slot_number: 50 ,
356
337
block_hash: "block_hash-123" . to_string( ) ,
357
- immutable_file_number: 0
358
338
} ) ,
359
339
transaction_result
360
340
) ;
@@ -373,10 +353,10 @@ mod tests {
373
353
374
354
repository
375
355
. create_transactions ( vec ! [
376
- CardanoTransactionRecord :: new( "tx_hash-123" , 10 , 50 , "block_hash-123" , 1234 ) ,
377
- CardanoTransactionRecord :: new( "tx_hash-456" , 11 , 51 , "block_hash-456" , 1234 ) ,
378
- CardanoTransactionRecord :: new( "tx_hash-789" , 12 , 52 , "block_hash-789" , 1234 ) ,
379
- CardanoTransactionRecord :: new( "tx_hash-000" , 101 , 100 , "block_hash-000" , 1234 ) ,
356
+ CardanoTransactionRecord :: new( "tx_hash-123" , 10 , 50 , "block_hash-123" ) ,
357
+ CardanoTransactionRecord :: new( "tx_hash-456" , 11 , 51 , "block_hash-456" ) ,
358
+ CardanoTransactionRecord :: new( "tx_hash-789" , 12 , 52 , "block_hash-789" ) ,
359
+ CardanoTransactionRecord :: new( "tx_hash-000" , 101 , 100 , "block_hash-000" ) ,
380
360
] )
381
361
. await
382
362
. unwrap ( ) ;
@@ -389,8 +369,8 @@ mod tests {
389
369
390
370
assert_eq ! (
391
371
vec![
392
- CardanoTransactionRecord :: new( "tx_hash-123" , 10 , 50 , "block_hash-123" , 1234 ) ,
393
- CardanoTransactionRecord :: new( "tx_hash-789" , 12 , 52 , "block_hash-789" , 1234 ) ,
372
+ CardanoTransactionRecord :: new( "tx_hash-123" , 10 , 50 , "block_hash-123" ) ,
373
+ CardanoTransactionRecord :: new( "tx_hash-789" , 12 , 52 , "block_hash-789" ) ,
394
374
] ,
395
375
transactions
396
376
) ;
@@ -403,8 +383,8 @@ mod tests {
403
383
404
384
assert_eq ! (
405
385
vec![
406
- CardanoTransactionRecord :: new( "tx_hash-123" , 10 , 50 , "block_hash-123" , 1234 ) ,
407
- CardanoTransactionRecord :: new( "tx_hash-789" , 12 , 52 , "block_hash-789" , 1234 ) ,
386
+ CardanoTransactionRecord :: new( "tx_hash-123" , 10 , 50 , "block_hash-123" ) ,
387
+ CardanoTransactionRecord :: new( "tx_hash-789" , 12 , 52 , "block_hash-789" ) ,
408
388
] ,
409
389
transactions
410
390
) ;
@@ -417,9 +397,9 @@ mod tests {
417
397
418
398
assert_eq ! (
419
399
vec![
420
- CardanoTransactionRecord :: new( "tx_hash-123" , 10 , 50 , "block_hash-123" , 1234 ) ,
421
- CardanoTransactionRecord :: new( "tx_hash-789" , 12 , 52 , "block_hash-789" , 1234 ) ,
422
- CardanoTransactionRecord :: new( "tx_hash-000" , 101 , 100 , "block_hash-000" , 1234 ) ,
400
+ CardanoTransactionRecord :: new( "tx_hash-123" , 10 , 50 , "block_hash-123" ) ,
401
+ CardanoTransactionRecord :: new( "tx_hash-789" , 12 , 52 , "block_hash-789" ) ,
402
+ CardanoTransactionRecord :: new( "tx_hash-000" , 101 , 100 , "block_hash-000" ) ,
423
403
] ,
424
404
transactions
425
405
) ;
@@ -442,11 +422,11 @@ mod tests {
442
422
) ) ;
443
423
444
424
repository
445
- . create_transaction ( "tx-hash-123" , 10 , 50 , "block_hash-123" , 99 )
425
+ . create_transaction ( "tx-hash-123" , 10 , 50 , "block_hash-123" )
446
426
. await
447
427
. unwrap ( ) ;
448
428
repository
449
- . create_transaction ( "tx-hash-123" , 11 , 51 , "block_hash-123-bis" , 100 )
429
+ . create_transaction ( "tx-hash-123" , 11 , 51 , "block_hash-123-bis" )
450
430
. await
451
431
. unwrap ( ) ;
452
432
let transaction_result = repository. get_transaction ( "tx-hash-123" ) . await . unwrap ( ) ;
@@ -457,7 +437,6 @@ mod tests {
457
437
block_number: 10 ,
458
438
slot_number: 50 ,
459
439
block_hash: "block_hash-123" . to_string( ) ,
460
- immutable_file_number: 99
461
440
} ) ,
462
441
transaction_result
463
442
) ;
@@ -487,7 +466,6 @@ mod tests {
487
466
block_number: 10 ,
488
467
slot_number: 50 ,
489
468
block_hash: "block-hash-123" . to_string( ) ,
490
- immutable_file_number: 0
491
469
} ) ,
492
470
transaction_result
493
471
) ;
@@ -500,7 +478,6 @@ mod tests {
500
478
block_number: 11 ,
501
479
slot_number: 51 ,
502
480
block_hash: "block-hash-456" . to_string( ) ,
503
- immutable_file_number: 0 ,
504
481
} ) ,
505
482
transaction_result
506
483
) ;
@@ -539,7 +516,7 @@ mod tests {
539
516
) ) ;
540
517
541
518
repository
542
- . create_transaction ( "tx-hash-000" , 1 , 5 , "block-hash" , 9 )
519
+ . create_transaction ( "tx-hash-000" , 1 , 5 , "block-hash" )
543
520
. await
544
521
. unwrap ( ) ;
545
522
@@ -562,7 +539,6 @@ mod tests {
562
539
block_number: 1 ,
563
540
slot_number: 5 ,
564
541
block_hash: "block-hash" . to_string( ) ,
565
- immutable_file_number: 9
566
542
} ) ,
567
543
transaction_result
568
544
) ;
@@ -644,43 +620,6 @@ mod tests {
644
620
) ;
645
621
}
646
622
647
- #[ tokio:: test]
648
- async fn repository_get_transaction_highest_immutable_file_number_without_transactions_in_db ( ) {
649
- let connection = cardano_tx_db_connection ( ) . unwrap ( ) ;
650
- let repository = CardanoTransactionRepository :: new ( Arc :: new (
651
- SqliteConnectionPool :: build_from_connection ( connection) ,
652
- ) ) ;
653
-
654
- let highest_beacon = repository
655
- . get_transaction_highest_immutable_file_number ( )
656
- . await
657
- . unwrap ( ) ;
658
- assert_eq ! ( None , highest_beacon) ;
659
- }
660
-
661
- #[ tokio:: test]
662
- async fn repository_get_transaction_highest_immutable_file_number_with_transactions_in_db ( ) {
663
- let connection = cardano_tx_db_connection ( ) . unwrap ( ) ;
664
- let repository = CardanoTransactionRepository :: new ( Arc :: new (
665
- SqliteConnectionPool :: build_from_connection ( connection) ,
666
- ) ) ;
667
-
668
- let cardano_transactions = vec ! [
669
- CardanoTransactionRecord :: new( "tx-hash-123" . to_string( ) , 10 , 50 , "block-hash-123" , 50 ) ,
670
- CardanoTransactionRecord :: new( "tx-hash-456" . to_string( ) , 11 , 51 , "block-hash-456" , 100 ) ,
671
- ] ;
672
- repository
673
- . create_transactions ( cardano_transactions)
674
- . await
675
- . unwrap ( ) ;
676
-
677
- let highest_beacon = repository
678
- . get_transaction_highest_immutable_file_number ( )
679
- . await
680
- . unwrap ( ) ;
681
- assert_eq ! ( Some ( 100 ) , highest_beacon) ;
682
- }
683
-
684
623
#[ tokio:: test]
685
624
async fn repository_get_transactions_in_range_blocks ( ) {
686
625
let connection = cardano_tx_db_connection ( ) . unwrap ( ) ;
@@ -689,9 +628,9 @@ mod tests {
689
628
) ) ;
690
629
691
630
let transactions = vec ! [
692
- CardanoTransactionRecord :: new( "tx-hash-1" , 10 , 50 , "block-hash-1" , 99 ) ,
693
- CardanoTransactionRecord :: new( "tx-hash-2" , 11 , 51 , "block-hash-2" , 100 ) ,
694
- CardanoTransactionRecord :: new( "tx-hash-3" , 12 , 52 , "block-hash-3" , 101 ) ,
631
+ CardanoTransactionRecord :: new( "tx-hash-1" , 10 , 50 , "block-hash-1" ) ,
632
+ CardanoTransactionRecord :: new( "tx-hash-2" , 11 , 51 , "block-hash-2" ) ,
633
+ CardanoTransactionRecord :: new( "tx-hash-3" , 12 , 52 , "block-hash-3" ) ,
695
634
] ;
696
635
repository
697
636
. create_transactions ( transactions. clone ( ) )
@@ -743,12 +682,12 @@ mod tests {
743
682
) ) ;
744
683
745
684
let transactions = vec ! [
746
- CardanoTransactionRecord :: new( "tx-hash-1" , 10 , 50 , "block-hash-1" , 99 ) ,
747
- CardanoTransactionRecord :: new( "tx-hash-2" , 11 , 51 , "block-hash-2" , 100 ) ,
748
- CardanoTransactionRecord :: new( "tx-hash-3" , 20 , 52 , "block-hash-3" , 101 ) ,
749
- CardanoTransactionRecord :: new( "tx-hash-4" , 31 , 53 , "block-hash-4" , 102 ) ,
750
- CardanoTransactionRecord :: new( "tx-hash-5" , 35 , 54 , "block-hash-5" , 103 ) ,
751
- CardanoTransactionRecord :: new( "tx-hash-6" , 46 , 55 , "block-hash-6" , 104 ) ,
685
+ CardanoTransactionRecord :: new( "tx-hash-1" , 10 , 50 , "block-hash-1" ) ,
686
+ CardanoTransactionRecord :: new( "tx-hash-2" , 11 , 51 , "block-hash-2" ) ,
687
+ CardanoTransactionRecord :: new( "tx-hash-3" , 20 , 52 , "block-hash-3" ) ,
688
+ CardanoTransactionRecord :: new( "tx-hash-4" , 31 , 53 , "block-hash-4" ) ,
689
+ CardanoTransactionRecord :: new( "tx-hash-5" , 35 , 54 , "block-hash-5" ) ,
690
+ CardanoTransactionRecord :: new( "tx-hash-6" , 46 , 55 , "block-hash-6" ) ,
752
691
] ;
753
692
repository
754
693
. create_transactions ( transactions. clone ( ) )
@@ -802,9 +741,9 @@ mod tests {
802
741
) ) ;
803
742
804
743
let transactions = vec ! [
805
- CardanoTransactionRecord :: new( "tx-1" , 100 , 500 , "block-1" , 99 ) ,
806
- CardanoTransactionRecord :: new( "tx-2" , 100 , 500 , "block-1" , 99 ) ,
807
- CardanoTransactionRecord :: new( "tx-3" , 101 , 501 , "block-1" , 99 ) ,
744
+ CardanoTransactionRecord :: new( "tx-1" , 100 , 500 , "block-1" ) ,
745
+ CardanoTransactionRecord :: new( "tx-2" , 100 , 500 , "block-1" ) ,
746
+ CardanoTransactionRecord :: new( "tx-3" , 101 , 501 , "block-1" ) ,
808
747
] ;
809
748
repository
810
749
. create_transactions ( transactions. clone ( ) )
0 commit comments