@@ -44,7 +44,9 @@ pub enum ChainTip {
44
44
}
45
45
46
46
/// The `Validate` trait defines behavior for validating chain data.
47
- pub ( crate ) trait Validate {
47
+ ///
48
+ /// This trait is sealed and not meant to be implemented outside of this crate.
49
+ pub trait Validate : sealed:: Validate {
48
50
/// The validated data wrapper which can be dereferenced to obtain the validated data.
49
51
type T : std:: ops:: Deref < Target = Self > ;
50
52
@@ -156,16 +158,24 @@ impl std::ops::Deref for ValidatedBlock {
156
158
}
157
159
}
158
160
161
+ mod sealed {
162
+ /// Used to prevent implementing [`super::Validate`] outside the crate but still allow its use.
163
+ pub trait Validate { }
164
+
165
+ impl Validate for crate :: BlockHeaderData { }
166
+ impl Validate for bitcoin:: blockdata:: block:: Block { }
167
+ }
168
+
159
169
/// The canonical `Poll` implementation used for a single `BlockSource`.
160
170
///
161
- /// Other `Poll` implementations must be built using `ChainPoller` as it provides the only means of
162
- /// validating chain data.
163
- pub struct ChainPoller < B : DerefMut < Target =T > + Sized , T : BlockSource > {
171
+ /// Other `Poll` implementations should be built using `ChainPoller` as it provides the simplest way
172
+ /// of validating chain data and checking consistency .
173
+ pub struct ChainPoller < B : DerefMut < Target =T > + Sized , T : BlockSource > {
164
174
block_source : B ,
165
175
network : Network ,
166
176
}
167
177
168
- impl < B : DerefMut < Target =T > + Sized , T : BlockSource > ChainPoller < B , T > {
178
+ impl < B : DerefMut < Target =T > + Sized , T : BlockSource > ChainPoller < B , T > {
169
179
/// Creates a new poller for the given block source.
170
180
///
171
181
/// If the `network` parameter is mainnet, then the difficulty between blocks is checked for
0 commit comments