Skip to content

Commit fdb4143

Browse files
committed
refactor: remove TxNode's _unconfirmed suffix for consistency
1 parent 716361c commit fdb4143

File tree

2 files changed

+15
-18
lines changed

2 files changed

+15
-18
lines changed

crates/chain/src/tx_graph.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,9 @@ pub struct TxNode<'a, T, A> {
217217
/// The blocks that the transaction is "anchored" in.
218218
pub anchors: &'a BTreeSet<A>,
219219
/// The first-seen unix timestamp of the transaction as unconfirmed.
220-
pub first_seen_unconfirmed: Option<u64>,
220+
pub first_seen: Option<u64>,
221221
/// The last-seen unix timestamp of the transaction as unconfirmed.
222-
pub last_seen_unconfirmed: Option<u64>,
222+
pub last_seen: Option<u64>,
223223
}
224224

225225
impl<T, A> Deref for TxNode<'_, T, A> {
@@ -341,8 +341,8 @@ impl<A> TxGraph<A> {
341341
txid,
342342
tx: tx.clone(),
343343
anchors: self.anchors.get(&txid).unwrap_or(&self.empty_anchors),
344-
first_seen_unconfirmed: self.first_seen.get(&txid).copied(),
345-
last_seen_unconfirmed: self.last_seen.get(&txid).copied(),
344+
first_seen: self.first_seen.get(&txid).copied(),
345+
last_seen: self.last_seen.get(&txid).copied(),
346346
}),
347347
TxNodeInternal::Partial(_) => None,
348348
})
@@ -353,7 +353,7 @@ impl<A> TxGraph<A> {
353353
&self,
354354
) -> impl Iterator<Item = TxNode<'_, Arc<Transaction>, A>> {
355355
self.full_txs().filter_map(|tx| {
356-
if tx.anchors.is_empty() && tx.last_seen_unconfirmed.is_none() {
356+
if tx.anchors.is_empty() && tx.last_seen.is_none() {
357357
Some(tx)
358358
} else {
359359
None
@@ -377,8 +377,8 @@ impl<A> TxGraph<A> {
377377
txid,
378378
tx: tx.clone(),
379379
anchors: self.anchors.get(&txid).unwrap_or(&self.empty_anchors),
380-
first_seen_unconfirmed: self.first_seen.get(&txid).copied(),
381-
last_seen_unconfirmed: self.last_seen.get(&txid).copied(),
380+
first_seen: self.first_seen.get(&txid).copied(),
381+
last_seen: self.last_seen.get(&txid).copied(),
382382
}),
383383
_ => None,
384384
}
@@ -1023,13 +1023,13 @@ impl<A: Anchor> TxGraph<A> {
10231023
transitively: None,
10241024
},
10251025
None => ChainPosition::Unconfirmed {
1026-
first_seen: tx_node.first_seen_unconfirmed,
1027-
last_seen: tx_node.last_seen_unconfirmed,
1026+
first_seen: tx_node.first_seen,
1027+
last_seen: tx_node.last_seen,
10281028
},
10291029
},
10301030
None => ChainPosition::Unconfirmed {
1031-
first_seen: tx_node.first_seen_unconfirmed,
1032-
last_seen: tx_node.last_seen_unconfirmed,
1031+
first_seen: tx_node.first_seen,
1032+
last_seen: tx_node.last_seen,
10331033
},
10341034
},
10351035
CanonicalReason::Anchor { anchor, descendant } => match descendant {
@@ -1050,11 +1050,11 @@ impl<A: Anchor> TxGraph<A> {
10501050
},
10511051
CanonicalReason::ObservedIn { observed_in, .. } => match observed_in {
10521052
ObservedIn::Mempool(last_seen) => ChainPosition::Unconfirmed {
1053-
first_seen: tx_node.first_seen_unconfirmed,
1053+
first_seen: tx_node.first_seen,
10541054
last_seen: Some(last_seen),
10551055
},
10561056
ObservedIn::Block(_) => ChainPosition::Unconfirmed {
1057-
first_seen: tx_node.first_seen_unconfirmed,
1057+
first_seen: tx_node.first_seen,
10581058
last_seen: None,
10591059
},
10601060
},

crates/chain/tests/test_tx_graph.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,10 +1326,7 @@ fn call_map_anchors_with_non_deterministic_anchor() {
13261326
let new_txnode = new_txs.next().unwrap();
13271327
assert_eq!(new_txnode.txid, tx_node.txid);
13281328
assert_eq!(new_txnode.tx, tx_node.tx);
1329-
assert_eq!(
1330-
new_txnode.last_seen_unconfirmed,
1331-
tx_node.last_seen_unconfirmed
1332-
);
1329+
assert_eq!(new_txnode.last_seen, tx_node.last_seen);
13331330
assert_eq!(new_txnode.anchors.len(), tx_node.anchors.len());
13341331

13351332
let mut new_anchors: Vec<_> = new_txnode.anchors.iter().map(|a| a.anchor_block).collect();
@@ -1543,6 +1540,6 @@ fn test_get_first_seen_of_a_tx() {
15431540
let changeset_seen = graph.insert_seen_at(txid, seen_at);
15441541
graph.apply_changeset(changeset_seen);
15451542

1546-
let first_seen = graph.get_tx_node(txid).unwrap().first_seen_unconfirmed;
1543+
let first_seen = graph.get_tx_node(txid).unwrap().first_seen;
15471544
assert_eq!(first_seen, Some(seen_at));
15481545
}

0 commit comments

Comments
 (0)