Trait hotshot::traits::ValidatedState
pub trait ValidatedState<TYPES>: Serialize + DeserializeOwned + Debug + Default + PartialEq + Eq + Send + Sync + Clonewhere
TYPES: NodeType,{
type Error: Error + Debug + Send + Sync;
type Instance: InstanceState;
type Delta: StateDelta;
type Time: ConsensusTime;
// Required methods
fn validate_and_apply_header(
&self,
instance: &Self::Instance,
parent_leaf: &Leaf<TYPES>,
proposed_header: &<TYPES as NodeType>::BlockHeader,
vid_common: <VidSchemeType as VidScheme>::Common,
version: Version
) -> impl Future<Output = Result<(Self, Self::Delta), Self::Error>> + Send;
fn from_header(block_header: &<TYPES as NodeType>::BlockHeader) -> Self;
fn genesis(instance: &Self::Instance) -> (Self, Self::Delta);
fn on_commit(&self);
}
Expand description
Abstraction over the state that blocks modify
This trait represents the behaviors that the ‘global’ ledger state must have:
- A defined error type (
Error
) - The type of block that modifies this type of state (
BlockPayload
(ValidatedStates:: BlockPayload
)) - The ability to validate that a block header is actually a valid extension of this state and
produce a new state, with the modifications from the block applied
(
validate_and_apply_header
)
Required Associated Types§
type Instance: InstanceState
type Instance: InstanceState
The type of the instance-level state this state is associated with
type Delta: StateDelta
type Delta: StateDelta
The type of the state delta this state is associated with.
type Time: ConsensusTime
type Time: ConsensusTime
Time compatibility needed for reward collection
Required Methods§
fn validate_and_apply_header(
&self,
instance: &Self::Instance,
parent_leaf: &Leaf<TYPES>,
proposed_header: &<TYPES as NodeType>::BlockHeader,
vid_common: <VidSchemeType as VidScheme>::Common,
version: Version
) -> impl Future<Output = Result<(Self, Self::Delta), Self::Error>> + Send
fn validate_and_apply_header( &self, instance: &Self::Instance, parent_leaf: &Leaf<TYPES>, proposed_header: &<TYPES as NodeType>::BlockHeader, vid_common: <VidSchemeType as VidScheme>::Common, version: Version ) -> impl Future<Output = Result<(Self, Self::Delta), Self::Error>> + Send
fn from_header(block_header: &<TYPES as NodeType>::BlockHeader) -> Self
fn from_header(block_header: &<TYPES as NodeType>::BlockHeader) -> Self
Construct the state with the given block header.
This can also be used to rebuild the state for catchup.
fn on_commit(&self)
fn on_commit(&self)
Gets called to notify the persistence backend that this state has been committed
Object Safety§
This trait is not object safe.