File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,11 @@ use std::ops::DerefMut;
8
8
9
9
/// The `Poll` trait defines behavior for polling block sources for a chain tip and retrieving
10
10
/// 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
11
16
pub trait Poll {
12
17
/// Returns a chain tip in terms of its relationship to the provided chain tip.
13
18
fn poll_chain_tip < ' a > ( & ' a mut self , best_known_chain_tip : ValidatedBlockHeader ) ->
@@ -149,12 +154,20 @@ impl std::ops::Deref for ValidatedBlock {
149
154
}
150
155
}
151
156
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.
152
161
pub struct ChainPoller < B : DerefMut < Target =T > + Sized + Sync + Send , T : BlockSource > {
153
162
block_source : B ,
154
163
network : Network ,
155
164
}
156
165
157
166
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.
158
171
pub fn new ( block_source : B , network : Network ) -> Self {
159
172
Self { block_source, network }
160
173
}
You can’t perform that action at this time.
0 commit comments