Skip to content

Commit 251bd7e

Browse files
committed
refactor(chain): Make private fields in CanonicalIter concise.
1 parent 944e3cc commit 251bd7e

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
@@ -13,10 +13,10 @@ pub struct CanonicalIter<'g, A, C> {
1313
chain: &'g C,
1414
chain_tip: BlockId,
1515

16-
unprocessed_txs_with_anchors:
16+
unprocessed_anchored_txs:
1717
Box<dyn Iterator<Item = (Txid, Arc<Transaction>, &'g BTreeSet<A>)> + 'g>,
18-
unprocessed_txs_with_last_seens: Box<dyn Iterator<Item = (Txid, Arc<Transaction>, u64)> + 'g>,
19-
unprocessed_txs_left_over: VecDeque<(Txid, Arc<Transaction>, u32)>,
18+
unprocessed_seen_txs: Box<dyn Iterator<Item = (Txid, Arc<Transaction>, u64)> + 'g>,
19+
unprocessed_leftover_txs: VecDeque<(Txid, Arc<Transaction>, u32)>,
2020

2121
canonical: HashMap<Txid, (Arc<Transaction>, CanonicalReason<A>)>,
2222
not_canonical: HashSet<Txid>,
@@ -28,12 +28,12 @@ impl<'g, A: Anchor, C: ChainOracle> CanonicalIter<'g, A, C> {
2828
/// Constructs [`CanonicalIter`].
2929
pub fn new(tx_graph: &'g TxGraph<A>, chain: &'g C, chain_tip: BlockId) -> Self {
3030
let anchors = tx_graph.all_anchors();
31-
let pending_anchored = Box::new(
31+
let unprocessed_anchored_txs = Box::new(
3232
tx_graph
3333
.txids_by_descending_anchor_height()
3434
.filter_map(|(_, txid)| Some((txid, tx_graph.get_tx(txid)?, anchors.get(&txid)?))),
3535
);
36-
let pending_last_seen = Box::new(
36+
let unprocessed_seen_txs = Box::new(
3737
tx_graph
3838
.txids_by_descending_last_seen()
3939
.filter_map(|(last_seen, txid)| Some((txid, tx_graph.get_tx(txid)?, last_seen))),
@@ -42,9 +42,9 @@ impl<'g, A: Anchor, C: ChainOracle> CanonicalIter<'g, A, C> {
4242
tx_graph,
4343
chain,
4444
chain_tip,
45-
unprocessed_txs_with_anchors: pending_anchored,
46-
unprocessed_txs_with_last_seens: pending_last_seen,
47-
unprocessed_txs_left_over: VecDeque::new(),
45+
unprocessed_anchored_txs,
46+
unprocessed_seen_txs,
47+
unprocessed_leftover_txs: VecDeque::new(),
4848
canonical: HashMap::new(),
4949
not_canonical: HashSet::new(),
5050
queue: VecDeque::new(),
@@ -73,7 +73,7 @@ impl<'g, A: Anchor, C: ChainOracle> CanonicalIter<'g, A, C> {
7373
}
7474
}
7575
// cannot determine
76-
self.unprocessed_txs_left_over.push_back((
76+
self.unprocessed_leftover_txs.push_back((
7777
txid,
7878
tx,
7979
anchors
@@ -147,7 +147,7 @@ impl<A: Anchor, C: ChainOracle> Iterator for CanonicalIter<'_, A, C> {
147147
return Some(Ok((txid, tx, reason)));
148148
}
149149

150-
if let Some((txid, tx, anchors)) = self.unprocessed_txs_with_anchors.next() {
150+
if let Some((txid, tx, anchors)) = self.unprocessed_anchored_txs.next() {
151151
if !self.is_canonicalized(txid) {
152152
if let Err(err) = self.scan_anchors(txid, tx, anchors) {
153153
return Some(Err(err));
@@ -156,15 +156,15 @@ impl<A: Anchor, C: ChainOracle> Iterator for CanonicalIter<'_, A, C> {
156156
continue;
157157
}
158158

159-
if let Some((txid, tx, last_seen)) = self.unprocessed_txs_with_last_seens.next() {
159+
if let Some((txid, tx, last_seen)) = self.unprocessed_seen_txs.next() {
160160
if !self.is_canonicalized(txid) {
161161
let observed_in = ObservedIn::Mempool(last_seen);
162162
self.mark_canonical(txid, tx, CanonicalReason::from_observed_in(observed_in));
163163
}
164164
continue;
165165
}
166166

167-
if let Some((txid, tx, height)) = self.unprocessed_txs_left_over.pop_front() {
167+
if let Some((txid, tx, height)) = self.unprocessed_leftover_txs.pop_front() {
168168
if !self.is_canonicalized(txid) {
169169
let observed_in = ObservedIn::Block(height);
170170
self.mark_canonical(txid, tx, CanonicalReason::from_observed_in(observed_in));

0 commit comments

Comments
 (0)