Skip to content

Commit d7f304e

Browse files
committed
f - Add missing ChainPoller documentation
1 parent 4546132 commit d7f304e

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

lightning-block-sync/src/poll.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ use std::ops::DerefMut;
88

99
/// The `Poll` trait defines behavior for polling block sources for a chain tip and retrieving
1010
/// related chain data. It serves as an adapter for `BlockSource`.
11+
///
12+
/// [`ChainPoller`] adapts a single `BlockSource`, while any other implementations of `Poll` are
13+
/// required to be built in terms of it to ensure chain data validity.
14+
///
15+
/// [`ChainPoller`]: ../struct.ChainPoller.html
1116
pub trait Poll {
1217
/// Returns a chain tip in terms of its relationship to the provided chain tip.
1318
fn poll_chain_tip<'a>(&'a mut self, best_known_chain_tip: ValidatedBlockHeader) ->
@@ -149,12 +154,20 @@ impl std::ops::Deref for ValidatedBlock {
149154
}
150155
}
151156

157+
/// The canonical `Poll` implementation used for a single `BlockSource`.
158+
///
159+
/// Other `Poll` implementations must be built using `ChainPoller` as it provides the only means of
160+
/// validating chain data.
152161
pub struct ChainPoller<B: DerefMut<Target=T> + Sized + Sync + Send, T: BlockSource> {
153162
block_source: B,
154163
network: Network,
155164
}
156165

157166
impl<B: DerefMut<Target=T> + Sized + Sync + Send, T: BlockSource> ChainPoller<B, T> {
167+
/// Creates a new poller for the given block source.
168+
///
169+
/// If the `network` parameter is mainnet, then the difficulty between blocks is checked for
170+
/// validity.
158171
pub fn new(block_source: B, network: Network) -> Self {
159172
Self { block_source, network }
160173
}

0 commit comments

Comments
 (0)