@@ -3,7 +3,6 @@ use std::sync::Arc;
3
3
4
4
use anyhow:: Context ;
5
5
use async_trait:: async_trait;
6
- use sqlite:: Value ;
7
6
8
7
use mithril_common:: cardano_block_scanner:: ImmutableLowerBoundFinder ;
9
8
use mithril_common:: crypto_helper:: MKTreeNode ;
@@ -52,27 +51,6 @@ impl CardanoTransactionRepository {
52
51
. fetch_collect ( GetCardanoTransactionQuery :: between_blocks ( range) )
53
52
}
54
53
55
- /// Return all the [CardanoTransactionRecord]s in the database up to the given beacon.
56
- ///
57
- /// Note: until we rely on block number based beacons, this function needs to compute the highest block number for the given immutable file number.
58
- pub async fn get_transactions_up_to (
59
- & self ,
60
- beacon : ImmutableFileNumber ,
61
- ) -> StdResult < Vec < CardanoTransactionRecord > > {
62
- // Get the highest block number for the given immutable number.
63
- // This is a temporary fix that will be removed when the retrieval is based on block number instead of immutable number.
64
-
65
- if let Some ( block_number) = self
66
- . get_highest_block_number_for_immutable_number ( beacon)
67
- . await ?
68
- {
69
- self . get_transactions_in_range_blocks ( 0 ..block_number + 1 )
70
- . await
71
- } else {
72
- Ok ( vec ! [ ] )
73
- }
74
- }
75
-
76
54
/// Return the [CardanoTransactionRecord] for the given transaction hash.
77
55
pub async fn get_transaction < T : Into < TransactionHash > > (
78
56
& self ,
@@ -128,24 +106,6 @@ impl CardanoTransactionRepository {
128
106
. fetch_collect ( InsertBlockRangeRootQuery :: insert_many ( records) ?)
129
107
}
130
108
131
- // TODO: remove this function when the Cardano transaction signature is based on block number instead of immutable number
132
- /// Get the highest [BlockNumber] of the cardano transactions stored in the database.
133
- pub async fn get_highest_block_number_for_immutable_number (
134
- & self ,
135
- immutable_file_number : ImmutableFileNumber ,
136
- ) -> StdResult < Option < BlockNumber > > {
137
- let highest: Option < i64 > = self . connection . query_single_cell (
138
- "select max(block_number) as highest from cardano_tx where immutable_file_number <= ?;" ,
139
- & [ Value :: Integer ( immutable_file_number as i64 ) ] ,
140
- ) ?;
141
- highest
142
- . map ( u64:: try_from)
143
- . transpose ( )
144
- . with_context ( ||
145
- format ! ( "Integer field max(block_number) (value={highest:?}) is incompatible with u64 representation." )
146
- )
147
- }
148
-
149
109
/// Get the highest [BlockNumber] of the cardano transactions stored in the database.
150
110
pub async fn get_transaction_highest_block_number ( & self ) -> StdResult < Option < BlockNumber > > {
151
111
let highest: Option < i64 > = self
@@ -464,60 +424,6 @@ mod tests {
464
424
) ;
465
425
}
466
426
467
- #[ tokio:: test]
468
- async fn repository_get_up_to_beacon_transactions ( ) {
469
- let connection = Arc :: new ( cardano_tx_db_connection ( ) . unwrap ( ) ) ;
470
- let repository = CardanoTransactionRepository :: new ( connection) ;
471
-
472
- let cardano_transactions: Vec < CardanoTransactionRecord > = CardanoTransactionsBuilder :: new ( )
473
- . max_transactions_per_immutable_file ( 10 )
474
- . first_immutable_file ( 120 )
475
- . build_transactions ( 40 )
476
- . into_iter ( )
477
- . map ( CardanoTransactionRecord :: from)
478
- . collect ( ) ;
479
-
480
- repository
481
- . create_transactions ( cardano_transactions. clone ( ) )
482
- . await
483
- . unwrap ( ) ;
484
-
485
- let transaction_result = repository. get_transactions_up_to ( 120 ) . await . unwrap ( ) ;
486
- let transaction_up_to_immutable_file_number_12 = cardano_transactions[ 0 ..10 ] . to_vec ( ) ;
487
- assert_eq ! (
488
- transaction_up_to_immutable_file_number_12,
489
- transaction_result
490
- ) ;
491
-
492
- let transaction_result = repository. get_transactions_up_to ( 300 ) . await . unwrap ( ) ;
493
- let transaction_all = cardano_transactions[ ..] . to_vec ( ) ;
494
- assert_eq ! ( transaction_all, transaction_result) ;
495
-
496
- let transaction_result = repository. get_transactions_up_to ( 90 ) . await . unwrap ( ) ;
497
- assert_eq ! ( Vec :: <CardanoTransactionRecord >:: new( ) , transaction_result) ;
498
- }
499
-
500
- #[ tokio:: test]
501
- async fn get_transactions_up_to_return_empty_list_when_no_record_found_with_provided_immutable_file_number (
502
- ) {
503
- let connection = Arc :: new ( cardano_tx_db_connection ( ) . unwrap ( ) ) ;
504
- let repository = CardanoTransactionRepository :: new ( connection) ;
505
-
506
- repository
507
- . create_transactions ( vec ! [ CardanoTransaction :: new(
508
- "tx-hash-123" . to_string( ) ,
509
- 0 ,
510
- 50 ,
511
- "block-hash-0" ,
512
- 99 ,
513
- ) ] )
514
- . await
515
- . unwrap ( ) ;
516
-
517
- let transaction_result = repository. get_transactions_up_to ( 90 ) . await . unwrap ( ) ;
518
- assert_eq ! ( Vec :: <CardanoTransactionRecord >:: new( ) , transaction_result) ;
519
- }
520
-
521
427
#[ tokio:: test]
522
428
async fn repository_get_all_stored_transactions ( ) {
523
429
let connection = Arc :: new ( cardano_tx_db_connection ( ) . unwrap ( ) ) ;
0 commit comments