Skip to main content

BlocksStateMachine

Struct BlocksStateMachine 

Source
pub struct BlocksStateMachine {
    pub forks: Forks<Slot>,
    /* private fields */
}
Expand description

Block State machine

This state machine is responsible for buffering blockstore events and provide a way to consume them in a controlled manner.

The entire blockstore state is logic is SANS-IO and must stay like this to ensure that we can test it properly.

IMPORTANT: SANS-IO means there is no IO operations in this state machine or async function that include channel communication.

Is to the developer to implement the IO part of the state machine by implementing your own “driver”.

Fields§

§forks: Forks<Slot>

Maintain forks history of the blockchain.

Implementations§

Source§

impl BlocksStateMachine

Source

pub fn new() -> Self

Creates a new blockstore instance

Source

pub fn stats(&self) -> BlockstoreStats

Source

pub fn is_slot_tracked(&self, slot: Slot) -> bool

Source

pub fn process_replay_event( &mut self, event: BlockReplayEvent, ) -> Result<(), UntrackedSlot>

Main entry point to process blockstore event and progress the state-machine.

Registers the event into the state machine and process any side effect that may arise from it.

Source

pub fn process_consensus_event(&mut self, event: ConsensusUpdate)

Source

pub fn oldest_block_in_buffer(&self) -> Option<OldestBufferedBlockInfo>

Returns the oldest block in the buffer.

Source

pub fn gc(&mut self, deleted: Option<&mut Vec<Slot>>) -> BlockstoreGCStats

This function will clean out deprecated slot index information from the state machine making sure it does not grow forever.

Stuff to “deindex” are : metadata about slot that are finalized – Since they are finalized we don’t need to keep them around anymore. Forked Slot – Slot that are forked and we know we will never reach finalized status for them.

Source

pub fn process_deregister_finalized_block_queue(&mut self)

Process the deregistered slot from the queue.

Source

pub fn pop_next_unprocess_blockstore_update( &mut self, ) -> Option<BlockStateMachineOutput>

Pops the next unprocessed blockstore update from the queue.

Source

pub fn unprocess_blockstore_update_queue_len(&self) -> usize

Source

pub fn pop_next_dlq(&mut self) -> Option<DeadletterEvent>

Trait Implementations§

Source§

impl Debug for BlocksStateMachine

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for BlocksStateMachine

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

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

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more