Skip to content

Commit 58fcf32

Browse files
committed
refactor(chain): Make private fields in CanonicalIter concise.
1 parent 5eb5e86 commit 58fcf32

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

crates/chain/src/canonical_iter.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ pub struct CanonicalIter<'g, A, C> {
1717
chain: &'g C,
1818
chain_tip: BlockId,
1919

20-
unprocessed_txs_with_anchors:
20+
unprocessed_anchored_txs:
2121
Box<dyn Iterator<Item = (Txid, Arc<Transaction>, &'g BTreeSet<A>)> + 'g>,
22-
unprocessed_txs_with_last_seens: Box<dyn Iterator<Item = (Txid, Arc<Transaction>, u64)> + 'g>,
23-
unprocessed_txs_left_over: VecDeque<(Txid, Arc<Transaction>, u32)>,
22+
unprocessed_seen_txs: Box<dyn Iterator<Item = (Txid, Arc<Transaction>, u64)> + 'g>,
23+
unprocessed_leftover_txs: VecDeque<(Txid, Arc<Transaction>, u32)>,
2424

2525
canonical: CanonicalMap<A>,
2626
not_canonical: NotCanonicalSet,
@@ -32,12 +32,12 @@ impl<'g, A: Anchor, C: ChainOracle> CanonicalIter<'g, A, C> {
3232
/// Constructs [`CanonicalIter`].
3333
pub fn new(tx_graph: &'g TxGraph<A>, chain: &'g C, chain_tip: BlockId) -> Self {
3434
let anchors = tx_graph.all_anchors();
35-
let pending_anchored = Box::new(
35+
let unprocessed_anchored_txs = Box::new(
3636
tx_graph
3737
.txids_by_descending_anchor_height()
3838
.filter_map(|(_, txid)| Some((txid, tx_graph.get_tx(txid)?, anchors.get(&txid)?))),
3939
);
40-
let pending_last_seen = Box::new(
40+
let unprocessed_seen_txs = Box::new(
4141
tx_graph
4242
.txids_by_descending_last_seen()
4343
.filter_map(|(last_seen, txid)| Some((txid, tx_graph.get_tx(txid)?, last_seen))),
@@ -46,9 +46,9 @@ impl<'g, A: Anchor, C: ChainOracle> CanonicalIter<'g, A, C> {
4646
tx_graph,
4747
chain,
4848
chain_tip,
49-
unprocessed_txs_with_anchors: pending_anchored,
50-
unprocessed_txs_with_last_seens: pending_last_seen,
51-
unprocessed_txs_left_over: VecDeque::new(),
49+
unprocessed_anchored_txs,
50+
unprocessed_seen_txs,
51+
unprocessed_leftover_txs: VecDeque::new(),
5252
canonical: HashMap::new(),
5353
not_canonical: HashSet::new(),
5454
queue: VecDeque::new(),
@@ -77,7 +77,7 @@ impl<'g, A: Anchor, C: ChainOracle> CanonicalIter<'g, A, C> {
7777
}
7878
}
7979
// cannot determine
80-
self.unprocessed_txs_left_over.push_back((
80+
self.unprocessed_leftover_txs.push_back((
8181
txid,
8282
tx,
8383
anchors
@@ -190,7 +190,7 @@ impl<A: Anchor, C: ChainOracle> Iterator for CanonicalIter<'_, A, C> {
190190
return Some(Ok((txid, tx, reason)));
191191
}
192192

193-
if let Some((txid, tx, anchors)) = self.unprocessed_txs_with_anchors.next() {
193+
if let Some((txid, tx, anchors)) = self.unprocessed_anchored_txs.next() {
194194
if !self.is_canonicalized(txid) {
195195
if let Err(err) = self.scan_anchors(txid, tx, anchors) {
196196
return Some(Err(err));
@@ -199,15 +199,15 @@ impl<A: Anchor, C: ChainOracle> Iterator for CanonicalIter<'_, A, C> {
199199
continue;
200200
}
201201

202-
if let Some((txid, tx, last_seen)) = self.unprocessed_txs_with_last_seens.next() {
202+
if let Some((txid, tx, last_seen)) = self.unprocessed_seen_txs.next() {
203203
if !self.is_canonicalized(txid) {
204204
let observed_in = ObservedIn::Mempool(last_seen);
205205
self.mark_canonical(txid, tx, CanonicalReason::from_observed_in(observed_in));
206206
}
207207
continue;
208208
}
209209

210-
if let Some((txid, tx, height)) = self.unprocessed_txs_left_over.pop_front() {
210+
if let Some((txid, tx, height)) = self.unprocessed_leftover_txs.pop_front() {
211211
if !self.is_canonicalized(txid) {
212212
let observed_in = ObservedIn::Block(height);
213213
self.mark_canonical(txid, tx, CanonicalReason::from_observed_in(observed_in));

0 commit comments

Comments
 (0)