Skip to content

Commit 3fb768b

Browse files
committed
feat(chain)!: Add last_evicted field to TxNode
Also remove `TxGraph::get_last_evicted` method.
1 parent 9613fd2 commit 3fb768b

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

crates/chain/src/tx_graph.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,8 @@ pub struct TxNode<'a, T, A> {
220220
pub first_seen: Option<u64>,
221221
/// The last-seen unix timestamp of the transaction as unconfirmed.
222222
pub last_seen: Option<u64>,
223+
/// The last-evicted-from-mempool unix timestamp of the transaction.
224+
pub last_evicted: Option<u64>,
223225
}
224226

225227
impl<T, A> Deref for TxNode<'_, T, A> {
@@ -342,6 +344,7 @@ impl<A> TxGraph<A> {
342344
anchors: self.anchors.get(&txid).unwrap_or(&self.empty_anchors),
343345
first_seen: self.first_seen.get(&txid).copied(),
344346
last_seen: self.last_seen.get(&txid).copied(),
347+
last_evicted: self.last_evicted.get(&txid).copied(),
345348
}),
346349
TxNodeInternal::Partial(_) => None,
347350
})
@@ -378,6 +381,7 @@ impl<A> TxGraph<A> {
378381
anchors: self.anchors.get(&txid).unwrap_or(&self.empty_anchors),
379382
first_seen: self.first_seen.get(&txid).copied(),
380383
last_seen: self.last_seen.get(&txid).copied(),
384+
last_evicted: self.last_evicted.get(&txid).copied(),
381385
}),
382386
_ => None,
383387
}
@@ -410,13 +414,6 @@ impl<A> TxGraph<A> {
410414
})
411415
}
412416

413-
/// Get the `last_evicted` timestamp of the given `txid`.
414-
///
415-
/// Ideally, this would be included in [`TxNode`], but that would be a breaking change.
416-
pub fn get_last_evicted(&self, txid: Txid) -> Option<u64> {
417-
self.last_evicted.get(&txid).copied()
418-
}
419-
420417
/// Calculates the fee of a given transaction. Returns [`Amount::ZERO`] if `tx` is a coinbase
421418
/// transaction. Returns `OK(_)` if we have all the [`TxOut`]s being spent by `tx` in the
422419
/// graph (either as the full transactions or individual txouts).

0 commit comments

Comments
 (0)