pub trait ValidatedState<TYPES: NodeType>:
Serialize
+ DeserializeOwned
+ Debug
+ Default
+ PartialEq
+ Eq
+ Send
+ Sync
+ Clone {
type Error: Error + Debug + Send + Sync;
type Instance: InstanceState;
type Delta: StateDelta;
// Required methods
fn validate_and_apply_header(
&self,
instance: &Self::Instance,
parent_leaf: &Leaf2<TYPES>,
proposed_header: &TYPES::BlockHeader,
payload_byte_len: Option<u32>,
version: Version,
view_number: u64,
) -> impl Future<Output = Result<(Self, Self::Delta), Self::Error>> + Send;
fn from_header(block_header: &TYPES::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
Required Associated Types§
Sourcetype Error: Error + Debug + Send + Sync
type Error: Error + Debug + Send + Sync
The error type for this particular type of ledger state
Sourcetype Instance: InstanceState
type Instance: InstanceState
The type of the instance-level state this state is associated with
Sourcetype Delta: StateDelta
type Delta: StateDelta
The type of the state delta this state is associated with.
Required Methods§
Sourcefn validate_and_apply_header(
&self,
instance: &Self::Instance,
parent_leaf: &Leaf2<TYPES>,
proposed_header: &TYPES::BlockHeader,
payload_byte_len: Option<u32>,
version: Version,
view_number: u64,
) -> impl Future<Output = Result<(Self, Self::Delta), Self::Error>> + Send
fn validate_and_apply_header( &self, instance: &Self::Instance, parent_leaf: &Leaf2<TYPES>, proposed_header: &TYPES::BlockHeader, payload_byte_len: Option<u32>, version: Version, view_number: u64, ) -> impl Future<Output = Result<(Self, Self::Delta), Self::Error>> + Send
Check if the proposed block header is valid and apply it to the state if so.
Returns the new state and state delta.
§Arguments
instance- Immutable instance-level state.payload_byte_len- Size of the block payload, orNonewhen the caller does not hold it. PassNoneonly for a proposal a quorum has already certified: the implementation skips the checks that depend on the payload size.
§Errors
If the block header is invalid or appending it would lead to an invalid state.
Sourcefn from_header(block_header: &TYPES::BlockHeader) -> Self
fn from_header(block_header: &TYPES::BlockHeader) -> Self
Construct the state with the given block header.
This can also be used to rebuild the state for catchup.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.