.expect(
"tx taken from `unprocessed_anchored_txs` so it must have at least one anchor",
)
- .confirmation_height(),
+ .anchor_block()
+ .height,
))
}
}
/// descendant, so the chain data may be confirmed in an earlier block.
pub fn confirmation_height_upper_bound(&self) -> Option<u32> {
match self {
- ChainPosition::Confirmed { anchor, .. } => Some(anchor.confirmation_height()),
+ ChainPosition::Confirmed { anchor, .. } => Some(anchor.anchor_block().height),
ChainPosition::Unconfirmed { .. } => None,
}
}
pub trait Anchor: core::fmt::Debug + Clone + Eq + PartialOrd + Ord + core::hash::Hash {
/// Returns the [`BlockId`] that the associated blockchain data is "anchored" in.
fn anchor_block(&self) -> BlockId;
-
- /// Get the height of the block that confirmed the associated chain data.
- ///
- /// This is the height of [`anchor_block`](Anchor::anchor_block).
- fn confirmation_height(&self) -> u32 {
- self.anchor_block().height
- }
}
impl<A: Anchor> Anchor for &A {
fn anchor_block(&self) -> BlockId {
<A as Anchor>::anchor_block(self)
}
-
- fn confirmation_height(&self) -> u32 {
- <A as Anchor>::confirmation_height(self)
- }
}
impl Anchor for BlockId {
// `txs_by_highest_conf_heights`.
// We want to remove `(old_top_h?, txid)` and insert `(new_top_h?, txid)`.
let mut old_top_h = None;
- let mut new_top_h = anchor.confirmation_height();
+ let mut new_top_h = anchor.anchor_block().height;
let is_changed = match self.anchors.entry(txid) {
hash_map::Entry::Occupied(mut e) => {
- old_top_h = e.get().iter().last().map(Anchor::confirmation_height);
+ old_top_h = e.get().iter().last().map(|a| a.anchor_block().height);
if let Some(old_top_h) = old_top_h {
if old_top_h > new_top_h {
new_top_h = old_top_h;