@@ -128,7 +128,7 @@ impl NetworkSeen {
128
128
/// This struct models an input that attempts to spend an output via a transaction path
129
129
/// that is not part of the canonical network view (e.g., evicted, conflicted, or unknown).
130
130
#[ derive( Debug , Clone ) ]
131
- pub struct SpendInfo < A > {
131
+ pub struct UncanonicalSpendInfo < A > {
132
132
/// Non-canonical ancestor transactions reachable from this input.
133
133
///
134
134
/// Each entry maps an ancestor `Txid` to its observed status in the network.
@@ -144,19 +144,19 @@ pub struct SpendInfo<A> {
144
144
/// position of the conflict.
145
145
///
146
146
/// [`uncanonical_ancestors`]: Self::uncanonical_ancestors
147
- pub conflicting_txs : BTreeMap < Txid , ChainPosition < A > > ,
147
+ pub canonical_conflicts : BTreeMap < Txid , ChainPosition < A > > ,
148
148
}
149
149
150
- impl < A > Default for SpendInfo < A > {
150
+ impl < A > Default for UncanonicalSpendInfo < A > {
151
151
fn default ( ) -> Self {
152
152
Self {
153
153
uncanonical_ancestors : BTreeMap :: new ( ) ,
154
- conflicting_txs : BTreeMap :: new ( ) ,
154
+ canonical_conflicts : BTreeMap :: new ( ) ,
155
155
}
156
156
}
157
157
}
158
158
159
- impl < A : Anchor > SpendInfo < A > {
159
+ impl < A : Anchor > UncanonicalSpendInfo < A > {
160
160
pub ( crate ) fn new < C > (
161
161
chain : & C ,
162
162
chain_tip : BlockId ,
@@ -205,7 +205,7 @@ impl<A: Anchor> SpendInfo<A> {
205
205
206
206
// Find conflicts to populate `conflicting_txs`.
207
207
if let Some ( ( conflict_txid, conflict_tx, reason) ) = network_view. spend ( prev_op) {
208
- let conflict_tx_entry = match spend_info. conflicting_txs . entry ( conflict_txid) {
208
+ let conflict_tx_entry = match spend_info. canonical_conflicts . entry ( conflict_txid) {
209
209
Entry :: Vacant ( vacant_entry) => vacant_entry,
210
210
// Skip if conflicting tx already visited.
211
211
Entry :: Occupied ( _) => continue ,
@@ -224,11 +224,12 @@ impl<A: Anchor> SpendInfo<A> {
224
224
225
225
// Find descendants of `conflict_tx` too.
226
226
for ( conflict_txid, _, reason) in network_view. descendants ( conflict_tx) {
227
- let conflict_tx_entry = match spend_info. conflicting_txs . entry ( conflict_txid) {
228
- Entry :: Vacant ( vacant_entry) => vacant_entry,
229
- // Skip if conflicting tx already visited.
230
- Entry :: Occupied ( _) => continue ,
231
- } ;
227
+ let conflict_tx_entry =
228
+ match spend_info. canonical_conflicts . entry ( conflict_txid) {
229
+ Entry :: Vacant ( vacant_entry) => vacant_entry,
230
+ // Skip if conflicting tx already visited.
231
+ Entry :: Occupied ( _) => continue ,
232
+ } ;
232
233
let conflict_tx_node = match tx_graph. get_tx_node ( conflict_txid) {
233
234
Some ( tx_node) => tx_node,
234
235
// Skip if conflict tx does not exist in our graph.
@@ -308,7 +309,7 @@ impl<A: Anchor> SpendInfo<A> {
308
309
/// If the spend info is empty, then it can belong in the canonical history without displacing
309
310
/// existing transactions or need to add additional transactions other than itself.
310
311
pub fn is_empty ( & self ) -> bool {
311
- self . uncanonical_ancestors . is_empty ( ) && self . conflicting_txs . is_empty ( )
312
+ self . uncanonical_ancestors . is_empty ( ) && self . canonical_conflicts . is_empty ( )
312
313
}
313
314
}
314
315
@@ -319,16 +320,17 @@ pub struct UncanonicalTx<A> {
319
320
pub txid : Txid ,
320
321
/// The uncanonical transaction.
321
322
pub tx : Arc < Transaction > ,
322
- /// Whether the transaction was one seen by the network.
323
+ /// Whether the transaction was once seen by the network.
323
324
pub network_seen : NetworkSeen ,
324
325
/// Spends, identified by prevout, which are uncanonical.
325
- pub uncanonical_spends : BTreeMap < OutPoint , SpendInfo < A > > ,
326
+ pub uncanonical_spends : BTreeMap < OutPoint , UncanonicalSpendInfo < A > > ,
326
327
}
327
328
328
329
impl < A : Anchor > UncanonicalTx < A > {
329
330
/// Whether the transaction was once observed in the network.
330
331
///
331
- /// Assuming that the chain-source does not lie, we can safely remove transactions that
332
+ /// Assuming that the chain-source does not lie, we can safely remove transactions that were
333
+ /// never seen by the network.
332
334
pub fn was_seen ( & self ) -> bool {
333
335
self . network_seen . was_seen ( )
334
336
}
@@ -355,14 +357,14 @@ impl<A: Anchor> UncanonicalTx<A> {
355
357
}
356
358
357
359
/// Iterate over transactions that are currently canonical in the network, but would be rendered
358
- /// uncanonical if this transaction were to become canonical.
360
+ /// uncanonical (be replaced) if this transaction were to become canonical.
359
361
///
360
362
/// This includes both direct and indirect conflicts, such as any transaction that relies on
361
363
/// conflicting ancestry.
362
364
pub fn conflicts ( & self ) -> impl Iterator < Item = ( Txid , & ChainPosition < A > ) > {
363
365
self . uncanonical_spends
364
366
. values ( )
365
- . flat_map ( |spend| & spend. conflicting_txs )
367
+ . flat_map ( |spend| & spend. canonical_conflicts )
366
368
. map ( |( & txid, pos) | ( txid, pos) )
367
369
. filter ( {
368
370
let mut dedup = HashSet :: < Txid > :: new ( ) ;
@@ -487,7 +489,7 @@ impl IntentTracker {
487
489
false
488
490
}
489
491
490
- /// Push a `txid` to the broadcast queue (if it does not exist already) and displaces all
492
+ /// Push a `txid` in the `IntentTracker` (if it does not exist already) and displaces all
491
493
/// coflicting txids in the queue.
492
494
pub fn push_and_displace_conflicts < A > ( & mut self , tx_graph : & TxGraph < A > , txid : Txid ) -> ChangeSet
493
495
where
0 commit comments