pub struct ChainStateBuilder<PersistedState: ChainStore> {
acc: Option<Stump>,
chainstore: Option<PersistedState>,
ibd: bool,
chain_params: Option<ChainParams>,
assume_valid: Option<BlockHash>,
tip: Option<(BlockHash, u32)>,
tip_header: Option<Header>,
}Expand description
A builder for configuring and creating a ChainState.
It implements a few methods to access and modify the settings. Call .build() to consume the
builder and produce the ChainState.
Fields§
§acc: Option<Stump>The accumulator stump.
chainstore: Option<PersistedState>The chain store.
ibd: boolIndicates whether the builder is in initial block download mode.
chain_params: Option<ChainParams>The chain parameters.
assume_valid: Option<BlockHash>The block hash that is assumed to be valid.
tip: Option<(BlockHash, u32)>The current chain tip.
tip_header: Option<Header>The first block header.
Implementations§
Source§impl<T: ChainStore> ChainStateBuilder<T>
impl<T: ChainStore> ChainStateBuilder<T>
Sourcepub fn build(self) -> Result<ChainState<T>, BlockchainBuilderError>
pub fn build(self) -> Result<ChainState<T>, BlockchainBuilderError>
Builds the chain state. Returns error if the chainstore or chain_params are missing, or
if only one of tip_header and tip is set (either set both or none).
Sourcepub fn with_chainstore(self, chainstore: T) -> Self
pub fn with_chainstore(self, chainstore: T) -> Self
Set the chainstore backend, implementing ChainStore. Always required.
Sourcepub fn toggle_ibd(self, ibd: bool) -> Self
pub fn toggle_ibd(self, ibd: bool) -> Self
Enable or disable Initial Block Download (IBD) mode.
Sourcepub fn with_chain_params(self, chain_params: ChainParams) -> Self
pub fn with_chain_params(self, chain_params: ChainParams) -> Self
Sets the chain parameters. Always required.
Sourcepub fn with_assume_valid(self, arg: AssumeValidArg, network: Network) -> Self
pub fn with_assume_valid(self, arg: AssumeValidArg, network: Network) -> Self
Sets the assume-valid argument, which can be Disabled, Hardcoded or UserInput. This
option is used to skip script validation up to the specified block, speeding up IBD.
Sourcepub fn assume_utreexo(self, acc: Stump) -> Self
pub fn assume_utreexo(self, acc: Stump) -> Self
Sets the utreexo accumulator, assumed as the initial state.
Sourcepub fn with_tip(self, tip: (BlockHash, u32), header: BlockHeader) -> Self
pub fn with_tip(self, tip: (BlockHash, u32), header: BlockHeader) -> Self
Sets the tip block data, assumed as the initial state.
Sourcepub(super) fn acc(&self) -> Option<Stump>
pub(super) fn acc(&self) -> Option<Stump>
Returns the utreexo accumulator that was set or None if empty.
Sourcepub(super) fn chainstore(&mut self) -> Result<T, BlockchainBuilderError>
pub(super) fn chainstore(&mut self) -> Result<T, BlockchainBuilderError>
Take the chainstore out of the builder, returning it or an error if missing.
Sourcepub(super) fn chain_params(&self) -> Result<ChainParams, BlockchainBuilderError>
pub(super) fn chain_params(&self) -> Result<ChainParams, BlockchainBuilderError>
Get the chain parameters, returning an error if they haven’t been set.
Sourcepub(super) fn best_block(&self) -> Result<BestChain, BlockchainBuilderError>
pub(super) fn best_block(&self) -> Result<BestChain, BlockchainBuilderError>
Get the specified best tip as a BestChain, or fall back to the genesis block if unset.
The returned validation index is always the genesis block (to skip script validation, you
must specify an assume_valid hash).
Returns an error if the chain parameters are missing.
Sourcepub(super) fn assume_valid(&self) -> Option<BlockHash>
pub(super) fn assume_valid(&self) -> Option<BlockHash>
Returns the block hash of the assume-valid option, if enabled.
Trait Implementations§
Source§impl<PersistedState: Clone + ChainStore> Clone for ChainStateBuilder<PersistedState>
impl<PersistedState: Clone + ChainStore> Clone for ChainStateBuilder<PersistedState>
Source§fn clone(&self) -> ChainStateBuilder<PersistedState>
fn clone(&self) -> ChainStateBuilder<PersistedState>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more