[][src]Struct beacon_chain::builder::BeaconChainBuilder

pub struct BeaconChainBuilder<T: BeaconChainTypes> {
    pub finalized_checkpoint: Option<CheckPoint<T::EthSpec>>,
    // some fields omitted
}

Builds a BeaconChain by either creating anew from genesis, or, resuming from an existing chain persisted to store.

Types may be elided and the compiler will infer them if all necessary builder methods have been called. If type inference errors are being raised, it is likely that not all required methods have been called.

See the tests for an example of a complete working example.

Fields

finalized_checkpoint: Option<CheckPoint<T::EthSpec>>

The finalized checkpoint to anchor the chain. May be genesis or a higher checkpoint.

Methods

impl<TStore, TSlotClock, TLmdGhost, TEth1Backend, TEthSpec, TEventHandler> BeaconChainBuilder<Witness<TStore, TSlotClock, TLmdGhost, TEth1Backend, TEthSpec, TEventHandler>> where
    TStore: Store + 'static,
    TSlotClock: SlotClock + 'static,
    TLmdGhost: LmdGhost<TStore, TEthSpec> + 'static,
    TEth1Backend: Eth1ChainBackend<TEthSpec> + 'static,
    TEthSpec: EthSpec + 'static,
    TEventHandler: EventHandler<TEthSpec> + 'static, 
[src]

pub fn new(_eth_spec_instance: TEthSpec) -> Self[src]

Returns a new builder.

The _eth_spec_instance parameter is only supplied to make concrete the TEthSpec trait. This should generally be either the MinimalEthSpec or MainnetEthSpec types.

pub fn custom_spec(self, spec: ChainSpec) -> Self[src]

Override the default spec (as defined by TEthSpec).

This method should generally be called immediately after Self::new to ensure components are started with a consistent spec.

pub fn store(self, store: Arc<TStore>) -> Self[src]

Sets the store (database).

Should generally be called early in the build chain.

pub fn logger(self, logger: Logger) -> Self[src]

Sets the logger.

Should generally be called early in the build chain.

pub fn resume_from_db(self) -> Result<Self, String>[src]

Attempt to load an existing chain from the builder's Store.

May initialize several components; including the op_pool and finalized checkpoints.

pub fn genesis_state(
    self,
    beacon_state: BeaconState<TEthSpec>
) -> Result<Self, String>
[src]

Starts a new chain from a genesis state.

pub fn fork_choice_backend(self, backend: TLmdGhost) -> Result<Self, String>[src]

Sets the BeaconChain fork choice backend.

Requires the store and state to have been specified earlier in the build chain.

pub fn eth1_backend(self, backend: Option<TEth1Backend>) -> Self[src]

Sets the BeaconChain eth1 backend.

pub fn event_handler(self, handler: TEventHandler) -> Self[src]

Sets the BeaconChain event handler backend.

For example, provide WebSocketSender as a handler.

pub fn slot_clock(self, clock: TSlotClock) -> Self[src]

Sets the BeaconChain slot clock.

For example, provide SystemTimeSlotClock as a clock.

pub fn build(
    self
) -> Result<BeaconChain<Witness<TStore, TSlotClock, TLmdGhost, TEth1Backend, TEthSpec, TEventHandler>>, String>
[src]

Consumes self, returning a BeaconChain if all required parameters have been supplied.

An error will be returned at runtime if all required parameters have not been configured.

Will also raise ambiguous type errors at compile time if some parameters have not been configured.

impl<TStore, TSlotClock, TEth1Backend, TEthSpec, TEventHandler> BeaconChainBuilder<Witness<TStore, TSlotClock, ThreadSafeReducedTree<TStore, TEthSpec>, TEth1Backend, TEthSpec, TEventHandler>> where
    TStore: Store + 'static,
    TSlotClock: SlotClock + 'static,
    TEth1Backend: Eth1ChainBackend<TEthSpec> + 'static,
    TEthSpec: EthSpec + 'static,
    TEventHandler: EventHandler<TEthSpec> + 'static, 
[src]

pub fn empty_reduced_tree_fork_choice(self) -> Result<Self, String>[src]

Initializes a new, empty (no recorded votes or blocks) fork choice, using the ThreadSafeReducedTree backend.

Requires the store and state to be initialized.

impl<TStore, TSlotClock, TLmdGhost, TEthSpec, TEventHandler> BeaconChainBuilder<Witness<TStore, TSlotClock, TLmdGhost, CachingEth1Backend<TEthSpec, TStore>, TEthSpec, TEventHandler>> where
    TStore: Store + 'static,
    TSlotClock: SlotClock + 'static,
    TLmdGhost: LmdGhost<TStore, TEthSpec> + 'static,
    TEthSpec: EthSpec + 'static,
    TEventHandler: EventHandler<TEthSpec> + 'static, 
[src]

pub fn caching_eth1_backend(
    self,
    backend: CachingEth1Backend<TEthSpec, TStore>
) -> Self
[src]

Sets the BeaconChain eth1 back-end to CachingEth1Backend.

pub fn no_eth1_backend(self) -> Self[src]

Do not use any eth1 backend. The client will not be able to produce beacon blocks.

pub fn dummy_eth1_backend(self) -> Result<Self, String>[src]

Sets the BeaconChain eth1 back-end to produce predictably junk data when producing blocks.

impl<TStore, TLmdGhost, TEth1Backend, TEthSpec, TEventHandler> BeaconChainBuilder<Witness<TStore, TestingSlotClock, TLmdGhost, TEth1Backend, TEthSpec, TEventHandler>> where
    TStore: Store + 'static,
    TLmdGhost: LmdGhost<TStore, TEthSpec> + 'static,
    TEth1Backend: Eth1ChainBackend<TEthSpec> + 'static,
    TEthSpec: EthSpec + 'static,
    TEventHandler: EventHandler<TEthSpec> + 'static, 
[src]

pub fn testing_slot_clock(self, slot_duration: Duration) -> Result<Self, String>[src]

Sets the BeaconChain slot clock to TestingSlotClock.

Requires the state to be initialized.

impl<TStore, TSlotClock, TLmdGhost, TEth1Backend, TEthSpec> BeaconChainBuilder<Witness<TStore, TSlotClock, TLmdGhost, TEth1Backend, TEthSpec, NullEventHandler<TEthSpec>>> where
    TStore: Store + 'static,
    TSlotClock: SlotClock + 'static,
    TLmdGhost: LmdGhost<TStore, TEthSpec> + 'static,
    TEth1Backend: Eth1ChainBackend<TEthSpec> + 'static,
    TEthSpec: EthSpec + 'static, 
[src]

pub fn null_event_handler(self) -> Self[src]

Sets the BeaconChain event handler to NullEventHandler.

Auto Trait Implementations

impl<T> Send for BeaconChainBuilder<T> where
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::EpochsPerHistoricalVector: Send,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::EpochsPerSlashingsVector: Send,
    <T as BeaconChainTypes>::Eth1Chain: Send,
    <T as BeaconChainTypes>::EthSpec: EthSpec + Send,
    <T as BeaconChainTypes>::EventHandler: Send,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::HistoricalRootsLimit: Send,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::JustificationBitsLength: Send,
    <T as BeaconChainTypes>::LmdGhost: Send,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxAttestations: Send,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxAttesterSlashings: Send,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxDeposits: Send,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxPendingAttestations: Send,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxProposerSlashings: Send,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxTransfers: Send,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxValidatorsPerCommittee: Send,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxVoluntaryExits: Send,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::ShardCount: Send,
    <T as BeaconChainTypes>::SlotClock: Send,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::SlotsPerEth1VotingPeriod: Send,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::SlotsPerHistoricalRoot: Send,
    <T as BeaconChainTypes>::Store: Send + Sync,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::ValidatorRegistryLimit: Send

impl<T> Unpin for BeaconChainBuilder<T> where
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::EpochsPerHistoricalVector: Unpin,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::EpochsPerSlashingsVector: Unpin,
    <T as BeaconChainTypes>::Eth1Chain: Unpin,
    <T as BeaconChainTypes>::EthSpec: EthSpec + Unpin,
    <T as BeaconChainTypes>::EventHandler: Unpin,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::HistoricalRootsLimit: Unpin,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::JustificationBitsLength: Unpin,
    <T as BeaconChainTypes>::LmdGhost: Unpin,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxAttestations: Unpin,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxAttesterSlashings: Unpin,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxDeposits: Unpin,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxPendingAttestations: Unpin,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxProposerSlashings: Unpin,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxTransfers: Unpin,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxValidatorsPerCommittee: Unpin,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxVoluntaryExits: Unpin,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::ShardCount: Unpin,
    <T as BeaconChainTypes>::SlotClock: Unpin,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::SlotsPerEth1VotingPeriod: Unpin,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::SlotsPerHistoricalRoot: Unpin,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::ValidatorRegistryLimit: Unpin

impl<T> Sync for BeaconChainBuilder<T> where
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::EpochsPerHistoricalVector: Sync,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::EpochsPerSlashingsVector: Sync,
    <T as BeaconChainTypes>::Eth1Chain: Sync,
    <T as BeaconChainTypes>::EthSpec: EthSpec + Sync,
    <T as BeaconChainTypes>::EventHandler: Sync,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::HistoricalRootsLimit: Sync,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::JustificationBitsLength: Sync,
    <T as BeaconChainTypes>::LmdGhost: Sync,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxAttestations: Sync,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxAttesterSlashings: Sync,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxDeposits: Sync,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxPendingAttestations: Sync,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxProposerSlashings: Sync,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxTransfers: Sync,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxValidatorsPerCommittee: Send + Sync,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxVoluntaryExits: Sync,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::ShardCount: Sync,
    <T as BeaconChainTypes>::SlotClock: Sync,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::SlotsPerEth1VotingPeriod: Sync,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::SlotsPerHistoricalRoot: Sync,
    <T as BeaconChainTypes>::Store: Send + Sync,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::ValidatorRegistryLimit: Sync

impl<T> UnwindSafe for BeaconChainBuilder<T> where
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::EpochsPerHistoricalVector: UnwindSafe,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::EpochsPerSlashingsVector: UnwindSafe,
    <T as BeaconChainTypes>::Eth1Chain: UnwindSafe,
    <T as BeaconChainTypes>::EthSpec: EthSpec + UnwindSafe,
    <T as BeaconChainTypes>::EventHandler: UnwindSafe,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::HistoricalRootsLimit: UnwindSafe,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::JustificationBitsLength: UnwindSafe,
    <T as BeaconChainTypes>::LmdGhost: UnwindSafe,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxAttestations: UnwindSafe,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxAttesterSlashings: UnwindSafe,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxDeposits: UnwindSafe,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxPendingAttestations: UnwindSafe,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxProposerSlashings: UnwindSafe,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxTransfers: UnwindSafe,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxValidatorsPerCommittee: UnwindSafe,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxVoluntaryExits: UnwindSafe,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::ShardCount: UnwindSafe,
    <T as BeaconChainTypes>::SlotClock: UnwindSafe,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::SlotsPerEth1VotingPeriod: UnwindSafe,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::SlotsPerHistoricalRoot: UnwindSafe,
    <T as BeaconChainTypes>::Store: RefUnwindSafe,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::ValidatorRegistryLimit: UnwindSafe

impl<T> !RefUnwindSafe for BeaconChainBuilder<T>

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> SendSyncUnwindSafe for T where
    T: Send + Sync + UnwindSafe + ?Sized

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

type Err = <U as TryFrom<T>>::Err

impl<T> Erased for T