Skip to content

Commit ade6ace

Browse files
committed
Remove MultipleChainPoller
1 parent 7af1dbe commit ade6ace

File tree

1 file changed

+0
-56
lines changed

1 file changed

+0
-56
lines changed

lightning-block-sync/src/poller.rs

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -47,62 +47,6 @@ impl<'b, B: DerefMut<Target=dyn BlockSource + 'b> + Sized + Sync + Send> Poll<'b
4747
}
4848
}
4949

50-
pub struct MultipleChainPoller<'a, B: DerefMut<Target=dyn BlockSource + 'a> + Sized + Sync + Send> {
51-
pollers: Vec<(ChainPoller<'a, B>, BlockSourceError)>,
52-
}
53-
54-
impl<'a, B: DerefMut<Target=dyn BlockSource + 'a> + Sized + Sync + Send> MultipleChainPoller<'a, B> {
55-
pub fn new(mut block_sources: Vec<B>) -> Self {
56-
let pollers = block_sources.drain(..).map(|block_source| {
57-
(ChainPoller::new(block_source), BlockSourceError::Transient)
58-
}).collect();
59-
Self { pollers }
60-
}
61-
}
62-
63-
impl<'b, B: DerefMut<Target=dyn BlockSource + 'b> + Sized + Sync + Send> Poll<'b, B> for MultipleChainPoller<'b, B> {
64-
fn poll_chain_tip<'a>(&'a mut self, best_chain_tip: BlockHeaderData) ->
65-
AsyncBlockSourceResult<'a, (ChainTip, &'a mut B::Target)>
66-
where 'b: 'a {
67-
Box::pin(async move {
68-
let mut heaviest_chain_tip = best_chain_tip;
69-
let mut best_result = Err(BlockSourceError::Persistent);
70-
for (poller, error) in self.pollers.iter_mut() {
71-
if let BlockSourceError::Persistent = error {
72-
continue;
73-
}
74-
75-
let result = poller.poll_chain_tip(heaviest_chain_tip).await;
76-
match result {
77-
Err(BlockSourceError::Persistent) => {
78-
*error = BlockSourceError::Persistent;
79-
},
80-
Err(BlockSourceError::Transient) => {
81-
if best_result.is_err() {
82-
best_result = result;
83-
}
84-
},
85-
Ok((ChainTip::Common, source)) => {
86-
if let Ok((ChainTip::Better(_, _), _)) = best_result {} else {
87-
best_result = Ok((ChainTip::Common, source));
88-
}
89-
},
90-
Ok((ChainTip::Better(_, header), _)) => {
91-
best_result = result;
92-
heaviest_chain_tip = header;
93-
},
94-
Ok((ChainTip::Worse(_, _), _)) => {
95-
if best_result.is_err() {
96-
best_result = result;
97-
}
98-
},
99-
}
100-
}
101-
best_result
102-
})
103-
}
104-
}
105-
10650
pub struct ChainMultiplexer<'b, B: DerefMut<Target=dyn BlockSource + 'b> + Sized + Sync + Send> {
10751
block_sources: Vec<(B, BlockSourceError)>,
10852
backup_block_sources: Vec<(B, BlockSourceError)>,

0 commit comments

Comments
 (0)