From: 志宇 Date: Wed, 10 Sep 2025 07:50:56 +0000 (+0000) Subject: feat(chain)!: Add `last_evicted` field to `TxNode` X-Git-Url: http://internal-gitweb-vhost/?a=commitdiff_plain;h=3fb768bd416b6979f938aacfc9ed681a64d4549f;p=bdk feat(chain)!: Add `last_evicted` field to `TxNode` Also remove `TxGraph::get_last_evicted` method. --- diff --git a/crates/chain/src/tx_graph.rs b/crates/chain/src/tx_graph.rs index 7bbdef63..ead2bfd7 100644 --- a/crates/chain/src/tx_graph.rs +++ b/crates/chain/src/tx_graph.rs @@ -220,6 +220,8 @@ pub struct TxNode<'a, T, A> { pub first_seen: Option, /// The last-seen unix timestamp of the transaction as unconfirmed. pub last_seen: Option, + /// The last-evicted-from-mempool unix timestamp of the transaction. + pub last_evicted: Option, } impl Deref for TxNode<'_, T, A> { @@ -342,6 +344,7 @@ impl TxGraph { anchors: self.anchors.get(&txid).unwrap_or(&self.empty_anchors), first_seen: self.first_seen.get(&txid).copied(), last_seen: self.last_seen.get(&txid).copied(), + last_evicted: self.last_evicted.get(&txid).copied(), }), TxNodeInternal::Partial(_) => None, }) @@ -378,6 +381,7 @@ impl TxGraph { anchors: self.anchors.get(&txid).unwrap_or(&self.empty_anchors), first_seen: self.first_seen.get(&txid).copied(), last_seen: self.last_seen.get(&txid).copied(), + last_evicted: self.last_evicted.get(&txid).copied(), }), _ => None, } @@ -410,13 +414,6 @@ impl TxGraph { }) } - /// Get the `last_evicted` timestamp of the given `txid`. - /// - /// Ideally, this would be included in [`TxNode`], but that would be a breaking change. - pub fn get_last_evicted(&self, txid: Txid) -> Option { - self.last_evicted.get(&txid).copied() - } - /// Calculates the fee of a given transaction. Returns [`Amount::ZERO`] if `tx` is a coinbase /// transaction. Returns `OK(_)` if we have all the [`TxOut`]s being spent by `tx` in the /// graph (either as the full transactions or individual txouts).