Skip to content

Commit 6eade6c

Browse files
committed
Remove now unused repository method fetching data using Immutables
Leaving only one required to compute the immutable block scanner lower bound.
1 parent 7c7da5a commit 6eade6c

File tree

3 files changed

+2
-112
lines changed

3 files changed

+2
-112
lines changed

internal/mithril-persistence/src/database/repository/cardano_transaction_repository.rs

Lines changed: 0 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use std::sync::Arc;
33

44
use anyhow::Context;
55
use async_trait::async_trait;
6-
use sqlite::Value;
76

87
use mithril_common::cardano_block_scanner::ImmutableLowerBoundFinder;
98
use mithril_common::crypto_helper::MKTreeNode;
@@ -52,27 +51,6 @@ impl CardanoTransactionRepository {
5251
.fetch_collect(GetCardanoTransactionQuery::between_blocks(range))
5352
}
5453

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-
7654
/// Return the [CardanoTransactionRecord] for the given transaction hash.
7755
pub async fn get_transaction<T: Into<TransactionHash>>(
7856
&self,
@@ -128,24 +106,6 @@ impl CardanoTransactionRepository {
128106
.fetch_collect(InsertBlockRangeRootQuery::insert_many(records)?)
129107
}
130108

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-
149109
/// Get the highest [BlockNumber] of the cardano transactions stored in the database.
150110
pub async fn get_transaction_highest_block_number(&self) -> StdResult<Option<BlockNumber>> {
151111
let highest: Option<i64> = self
@@ -464,60 +424,6 @@ mod tests {
464424
);
465425
}
466426

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-
521427
#[tokio::test]
522428
async fn repository_get_all_stored_transactions() {
523429
let connection = Arc::new(cardano_tx_db_connection().unwrap());

mithril-aggregator/src/database/repository/cardano_transaction_repository.rs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ use std::ops::Range;
33
use async_trait::async_trait;
44

55
use mithril_common::crypto_helper::MKTreeNode;
6-
use mithril_common::entities::{
7-
BlockNumber, BlockRange, CardanoDbBeacon, CardanoTransaction, TransactionHash,
8-
};
6+
use mithril_common::entities::{BlockNumber, BlockRange, CardanoTransaction, TransactionHash};
97
use mithril_common::StdResult;
108
use mithril_persistence::database::repository::CardanoTransactionRepository;
119

@@ -51,16 +49,6 @@ impl TransactionStore for CardanoTransactionRepository {
5149

5250
#[async_trait]
5351
impl TransactionsRetriever for CardanoTransactionRepository {
54-
async fn get_up_to(&self, beacon: &CardanoDbBeacon) -> StdResult<Vec<CardanoTransaction>> {
55-
self.get_transactions_up_to(beacon.immutable_file_number)
56-
.await
57-
.map(|v| {
58-
v.into_iter()
59-
.map(|record| record.into())
60-
.collect::<Vec<CardanoTransaction>>()
61-
})
62-
}
63-
6452
async fn get_by_hashes(
6553
&self,
6654
hashes: Vec<TransactionHash>,

mithril-aggregator/src/services/prover.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ use std::{
1010
use mithril_common::{
1111
crypto_helper::{MKMap, MKMapNode, MKTree},
1212
entities::{
13-
BlockRange, CardanoDbBeacon, CardanoTransaction, CardanoTransactionsSetProof, ChainPoint,
14-
TransactionHash,
13+
BlockRange, CardanoTransaction, CardanoTransactionsSetProof, ChainPoint, TransactionHash,
1514
},
1615
resource_pool::ResourcePool,
1716
signable_builder::BlockRangeRootRetriever,
@@ -37,9 +36,6 @@ pub trait ProverService: Sync + Send {
3736
#[cfg_attr(test, mockall::automock)]
3837
#[async_trait]
3938
pub trait TransactionsRetriever: Sync + Send {
40-
/// Get all transactions up to given beacon using chronological order
41-
async fn get_up_to(&self, beacon: &CardanoDbBeacon) -> StdResult<Vec<CardanoTransaction>>;
42-
4339
/// Get a list of transactions by hashes using chronological order
4440
async fn get_by_hashes(
4541
&self,

0 commit comments

Comments
 (0)