[bdk_chain_redesign] chain_oracle::Cache
Introduce `chain_oracle::Cache` which is a cache for requests to the chain oracle. `ChainOracle` has also been moved to the `chain_oracle` module. Introduce `get_tip_in_best_chain` method to the `ChainOracle` trait. This allows for guaranteeing that chain state can be consistent across operations with `IndexedTxGraph`.
This commit is contained in:
@@ -586,11 +586,12 @@ impl<A: Clone + Ord> TxGraph<A> {
|
||||
|
||||
impl<A: BlockAnchor> TxGraph<A> {
|
||||
/// Get all heights that are relevant to the graph.
|
||||
pub fn relevant_heights(&self) -> BTreeSet<u32> {
|
||||
pub fn relevant_heights(&self) -> impl Iterator<Item = u32> + '_ {
|
||||
let mut visited = HashSet::new();
|
||||
self.anchors
|
||||
.iter()
|
||||
.map(|(a, _)| a.anchor_block().height)
|
||||
.collect()
|
||||
.filter(move |&h| visited.insert(h))
|
||||
}
|
||||
|
||||
/// Determines whether a transaction of `txid` is in the best chain.
|
||||
|
||||
Reference in New Issue
Block a user