Skip to content

Commit faf520d

Browse files
committed
Merge #2028: Add last_evicted field to TxNode
3fb768b feat(chain)!: Add `last_evicted` field to `TxNode` (志宇) Pull request description: ### Description All `last_evicted` field to `TxNode` and remove `TxGraph::get_last_evicted` method. ### Notes to the reviewers `get_last_evicted` was added as adding fields to `TxNode` is a breaking change. However, we are going to break `bdk_chain` in the next release so a breaking change now is okay. ### Changelog notice ```md Added: - `last_evicted` field is added to `TxNode`. Removed: - `TxGraph::get_last_evicted` method is removed. ``` ### Checklists #### All Submissions: * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md) #### New Features: ~* [ ] I've added tests for the new feature~ * [x] I've added docs for the new feature ACKs for top commit: oleonardolima: ACK 3fb768b LagginTimes: ACK 3fb768b Tree-SHA512: 7dc5f68d8a49f10dc16e5ff5b00a02ee991eea832cd7ac96d454b5fb44067c868338921f428d8fdaad38e491c4f8f25baa119dc6de85b1e6c22cab36d95cb423
2 parents 2bf468c + 3fb768b commit faf520d

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)