@@ -671,11 +671,7 @@ impl<A: Clone + Ord> TxGraph<A> {
671
671
672
672
/// Inserts the given `seen_at` for `txid` into [`TxGraph`].
673
673
///
674
- /// Note that [`TxGraph`] only keeps track of the latest `seen_at`. To batch
675
- /// update all unconfirmed transactions with the latest `seen_at`, see
676
- /// [`update_last_seen_unconfirmed`].
677
- ///
678
- /// [`update_last_seen_unconfirmed`]: Self::update_last_seen_unconfirmed
674
+ /// Note that [`TxGraph`] only keeps track of the latest `seen_at`.
679
675
pub fn insert_seen_at ( & mut self , txid : Txid , seen_at : u64 ) -> ChangeSet < A > {
680
676
let mut changeset = ChangeSet :: < A > :: default ( ) ;
681
677
let last_seen = self . last_seen . entry ( txid) . or_default ( ) ;
@@ -686,65 +682,6 @@ impl<A: Clone + Ord> TxGraph<A> {
686
682
changeset
687
683
}
688
684
689
- /// Update the last seen time for all unconfirmed transactions.
690
- ///
691
- /// This method updates the last seen unconfirmed time for this [`TxGraph`] by inserting
692
- /// the given `seen_at` for every transaction not yet anchored to a confirmed block,
693
- /// and returns the [`ChangeSet`] after applying all updates to `self`.
694
- ///
695
- /// This is useful for keeping track of the latest time a transaction was seen
696
- /// unconfirmed, which is important for evaluating transaction conflicts in the same
697
- /// [`TxGraph`]. For details of how [`TxGraph`] resolves conflicts, see the docs for
698
- /// [`try_get_chain_position`].
699
- ///
700
- /// A normal use of this method is to call it with the current system time. Although
701
- /// block headers contain a timestamp, using the header time would be less effective
702
- /// at tracking mempool transactions, because it can drift from actual clock time, plus
703
- /// we may want to update a transaction's last seen time repeatedly between blocks.
704
- ///
705
- /// # Example
706
- ///
707
- /// ```rust
708
- /// # use bdk_chain::example_utils::*;
709
- /// # use std::time::UNIX_EPOCH;
710
- /// # let tx = tx_from_hex(RAW_TX_1);
711
- /// # let mut tx_graph = bdk_chain::TxGraph::<()>::new([tx]);
712
- /// let now = std::time::SystemTime::now()
713
- /// .duration_since(UNIX_EPOCH)
714
- /// .expect("valid duration")
715
- /// .as_secs();
716
- /// let changeset = tx_graph.update_last_seen_unconfirmed(now);
717
- /// assert!(!changeset.last_seen.is_empty());
718
- /// ```
719
- ///
720
- /// Note that [`TxGraph`] only keeps track of the latest `seen_at`, so the given time must
721
- /// by strictly greater than what is currently stored for a transaction to have an effect.
722
- /// To insert a last seen time for a single txid, see [`insert_seen_at`].
723
- ///
724
- /// [`insert_seen_at`]: Self::insert_seen_at
725
- /// [`try_get_chain_position`]: Self::try_get_chain_position
726
- pub fn update_last_seen_unconfirmed ( & mut self , seen_at : u64 ) -> ChangeSet < A > {
727
- let mut changeset = ChangeSet :: default ( ) ;
728
- let unanchored_txs: Vec < Txid > = self
729
- . txs
730
- . iter ( )
731
- . filter_map (
732
- |( & txid, ( _, anchors) ) | {
733
- if anchors. is_empty ( ) {
734
- Some ( txid)
735
- } else {
736
- None
737
- }
738
- } ,
739
- )
740
- . collect ( ) ;
741
-
742
- for txid in unanchored_txs {
743
- changeset. merge ( self . insert_seen_at ( txid, seen_at) ) ;
744
- }
745
- changeset
746
- }
747
-
748
685
/// Extends this graph with the given `update`.
749
686
///
750
687
/// The returned [`ChangeSet`] is the set difference between `update` and `self` (transactions that
0 commit comments