Skip to content

Commit baf3e08

Browse files
committed
Minor changes after review
- Fix comments typo - Rename function name - Change `from` type to `ImmutableFileNumber` in `parse_and_store_transactions_not_imported_yet` signature
1 parent 396ed9e commit baf3e08

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

mithril-aggregator/src/services/cardano_transactions_importer.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ impl CardanoTransactionsImporter {
6565
Ok(highest)
6666
}
6767

68-
async fn parse_and_store_missing_transactions(
68+
async fn parse_and_store_transactions_not_imported_yet(
6969
&self,
70-
from: Option<u64>,
70+
from: Option<ImmutableFileNumber>,
7171
until: ImmutableFileNumber,
7272
) -> StdResult<()> {
7373
if from.is_some_and(|f| f >= until) {
@@ -103,7 +103,7 @@ impl TransactionsImporter for CardanoTransactionsImporter {
103103
up_to_beacon: ImmutableFileNumber,
104104
) -> StdResult<Vec<CardanoTransaction>> {
105105
let from = self.get_starting_beacon().await?;
106-
self.parse_and_store_missing_transactions(from, up_to_beacon)
106+
self.parse_and_store_transactions_not_imported_yet(from, up_to_beacon)
107107
.await?;
108108

109109
let transactions = self.transaction_store.get_up_to(up_to_beacon).await?;

mithril-common/src/cardano_transaction_parser.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,9 @@ impl TransactionParser for CardanoTransactionParser {
207207
from_immutable: Option<ImmutableFileNumber>,
208208
until_immutable: ImmutableFileNumber,
209209
) -> StdResult<Vec<CardanoTransaction>> {
210-
let up_to_file_number = until_immutable;
211210
let is_in_bounds = |number: ImmutableFileNumber| match from_immutable {
212-
Some(from) => from <= number && number <= up_to_file_number,
213-
None => number <= up_to_file_number,
211+
Some(from) => (from..=until_immutable).contains(&number),
212+
None => number <= until_immutable,
214213
};
215214
let immutable_chunks = ImmutableFile::list_completed_in_dir(dirpath)?
216215
.into_iter()
@@ -278,7 +277,7 @@ mod tests {
278277

279278
#[tokio::test]
280279
async fn test_parse_expected_number_of_transactions() {
281-
// We known the number of transactions in those prebuilt immutables
280+
// We know the number of transactions in those prebuilt immutables
282281
let immutable_files = [("00000", 0usize), ("00001", 2), ("00002", 3)];
283282
let db_path = Path::new("../mithril-test-lab/test_data/immutable/");
284283
assert!(get_number_of_immutable_chunk_in_dir(db_path) >= 3);
@@ -298,7 +297,7 @@ mod tests {
298297

299298
#[tokio::test]
300299
async fn test_parse_from_lower_bound_until_upper_bound() {
301-
// We known the number of transactions in those prebuilt immutables
300+
// We know the number of transactions in those prebuilt immutables
302301
let immutable_files = [("00002", 3)];
303302
let db_path = Path::new("../mithril-test-lab/test_data/immutable/");
304303
assert!(get_number_of_immutable_chunk_in_dir(db_path) >= 3);
@@ -356,7 +355,7 @@ mod tests {
356355

357356
#[tokio::test]
358357
async fn test_parse_up_to_given_beacon() {
359-
// We known the number of transactions in those prebuilt immutables
358+
// We know the number of transactions in those prebuilt immutables
360359
let immutable_files = [("00000", 0usize), ("00001", 2)];
361360
let db_path = Path::new("../mithril-test-lab/test_data/immutable/");
362361
assert!(get_number_of_immutable_chunk_in_dir(db_path) >= 2);

mithril-signer/src/cardano_transactions_importer.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ impl CardanoTransactionsImporter {
6565
Ok(highest)
6666
}
6767

68-
async fn parse_and_store_missing_transactions(
68+
async fn parse_and_store_transactions_not_imported_yet(
6969
&self,
70-
from: Option<u64>,
70+
from: Option<ImmutableFileNumber>,
7171
until: ImmutableFileNumber,
7272
) -> StdResult<()> {
7373
if from.is_some_and(|f| f >= until) {
@@ -103,7 +103,7 @@ impl TransactionsImporter for CardanoTransactionsImporter {
103103
up_to_beacon: ImmutableFileNumber,
104104
) -> StdResult<Vec<CardanoTransaction>> {
105105
let from = self.get_starting_beacon().await?;
106-
self.parse_and_store_missing_transactions(from, up_to_beacon)
106+
self.parse_and_store_transactions_not_imported_yet(from, up_to_beacon)
107107
.await?;
108108

109109
let transactions = self.transaction_store.get_up_to(up_to_beacon).await?;

0 commit comments

Comments
 (0)