Skip to content

Commit 8e15481

Browse files
committed
Keep BlockRangeRootRetriever in the shared transaction repository
For this we need to enable `mithril-common` `fs` feature in `mithril-persistence`. This is fine since both nodes that use the persistence library also need this feature.
1 parent 824d562 commit 8e15481

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

internal/mithril-persistence/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ anyhow = "1.0.79"
1616
async-trait = "0.1.77"
1717
chrono = { version = "0.4.33", features = ["serde"] }
1818
hex = "0.4.3"
19-
mithril-common = { path = "../../mithril-common" }
19+
mithril-common = { path = "../../mithril-common", features = ["fs"] }
2020
semver = "1.0.21"
2121
serde = { version = "1.0.196", features = ["derive"] }
2222
serde_json = "1.0.113"

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ use std::ops::Range;
22
use std::sync::Arc;
33

44
use anyhow::Context;
5+
use async_trait::async_trait;
56
use sqlite::Value;
67

78
use mithril_common::crypto_helper::MKTreeNode;
89
use mithril_common::entities::{
910
BlockHash, BlockNumber, BlockRange, CardanoTransaction, ImmutableFileNumber, SlotNumber,
1011
TransactionHash,
1112
};
13+
use mithril_common::signable_builder::BlockRangeRootRetriever;
1214
use mithril_common::StdResult;
1315

1416
use crate::database::provider::{
@@ -300,6 +302,23 @@ impl CardanoTransactionRepository {
300302
}
301303
}
302304

305+
#[async_trait]
306+
impl BlockRangeRootRetriever for CardanoTransactionRepository {
307+
async fn retrieve_block_range_roots(
308+
&self,
309+
up_to_beacon: ImmutableFileNumber,
310+
) -> StdResult<Box<dyn Iterator<Item = (BlockRange, MKTreeNode)>>> {
311+
// Get the highest block number for the given immutable number.
312+
// This is a temporary fix that will be removed when the retrieval is based on block number instead of immutable number.
313+
let block_number = self
314+
.get_highest_block_number_for_immutable_number(up_to_beacon)
315+
.await?
316+
.unwrap_or(0);
317+
318+
self.retrieve_block_range_roots_up_to(block_number).await
319+
}
320+
}
321+
303322
#[cfg(test)]
304323
mod tests {
305324
use crate::database::provider::GetBlockRangeRootProvider;

0 commit comments

Comments
 (0)