From: Matt Corallo <649246+TheBlueMatt@users.noreply.github.com> Date: Fri, 18 Jun 2021 18:06:45 +0000 (+0000) Subject: Merge pull request #956 from jkczyz/2021-06-validate-pub X-Git-Tag: v0.0.99~21 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=4d1c1a32f20dcce2553ba7ec467e349fc37493c8;hp=244ad8349ef0b8bf4d679803f43c5b0389653138;p=rust-lightning Merge pull request #956 from jkczyz/2021-06-validate-pub Increase poll::Validate visibility to pub --- diff --git a/lightning-block-sync/src/poll.rs b/lightning-block-sync/src/poll.rs index fbe803b4..c59652ea 100644 --- a/lightning-block-sync/src/poll.rs +++ b/lightning-block-sync/src/poll.rs @@ -44,7 +44,9 @@ pub enum ChainTip { } /// The `Validate` trait defines behavior for validating chain data. -pub(crate) trait Validate { +/// +/// This trait is sealed and not meant to be implemented outside of this crate. +pub trait Validate: sealed::Validate { /// The validated data wrapper which can be dereferenced to obtain the validated data. type T: std::ops::Deref; @@ -156,16 +158,24 @@ impl std::ops::Deref for ValidatedBlock { } } +mod sealed { + /// Used to prevent implementing [`super::Validate`] outside the crate but still allow its use. + pub trait Validate {} + + impl Validate for crate::BlockHeaderData {} + impl Validate for bitcoin::blockdata::block::Block {} +} + /// The canonical `Poll` implementation used for a single `BlockSource`. /// -/// Other `Poll` implementations must be built using `ChainPoller` as it provides the only means of -/// validating chain data. -pub struct ChainPoller + Sized , T: BlockSource> { +/// Other `Poll` implementations should be built using `ChainPoller` as it provides the simplest way +/// of validating chain data and checking consistency. +pub struct ChainPoller + Sized, T: BlockSource> { block_source: B, network: Network, } -impl + Sized , T: BlockSource> ChainPoller { +impl + Sized, T: BlockSource> ChainPoller { /// Creates a new poller for the given block source. /// /// If the `network` parameter is mainnet, then the difficulty between blocks is checked for