Struct linera_chain::ChainManager
source · pub struct ChainManager {
pub ownership: ChainOwnership,
pub seed: u64,
pub distribution: Option<WeightedAliasIndex<u64>>,
pub proposed: Option<BlockProposal>,
pub locked: Option<Certificate>,
pub leader_timeout: Option<Certificate>,
pub pending: Option<Vote>,
pub timeout_vote: Option<Vote>,
pub round_timeout: Option<Timestamp>,
}
Expand description
The state of the certification process for a chain’s next block.
Fields§
§ownership: ChainOwnership
The public keys, weights and types of the chain’s owners.
seed: u64
The seed for the pseudo-random number generator that determines the round leaders.
distribution: Option<WeightedAliasIndex<u64>>
The probability distribution for choosing a round leader.
proposed: Option<BlockProposal>
Highest-round authenticated block that we have received and checked. If there are multiple proposals in the same round, this contains only the first one.
locked: Option<Certificate>
Latest validated proposal that we have voted to confirm (or would have, if we are not a validator).
leader_timeout: Option<Certificate>
Latest leader timeout certificate we have received.
pending: Option<Vote>
Latest vote we have cast, to validate or confirm.
timeout_vote: Option<Vote>
Latest timeout vote we cast.
round_timeout: Option<Timestamp>
The time after which we are ready to sign a timeout certificate for the current round.
Implementations§
source§impl ChainManager
impl ChainManager
sourcepub fn reset(
&mut self,
ownership: &ChainOwnership,
height: BlockHeight,
local_time: Timestamp
) -> Result<(), ChainError>
pub fn reset( &mut self, ownership: &ChainOwnership, height: BlockHeight, local_time: Timestamp ) -> Result<(), ChainError>
Replaces self
with a new chain manager.
sourcepub fn current_round(&self) -> Round
pub fn current_round(&self) -> Round
Returns the lowest round where we can still vote to validate or confirm a block. This is the round to which the current timeout applies.
Having a leader timeout certificate in any given round causes the next one to become current. Seeing a validated block certificate or a valid proposal in any round causes that round to become current, unless a higher one already is.
sourcepub fn check_proposed_block(
&self,
proposal: &BlockProposal
) -> Result<Outcome, ChainError>
pub fn check_proposed_block( &self, proposal: &BlockProposal ) -> Result<Outcome, ChainError>
Verifies the safety of a proposed block with respect to voting rules.
sourcepub fn vote_leader_timeout(
&mut self,
chain_id: ChainId,
height: BlockHeight,
epoch: Epoch,
key_pair: Option<&KeyPair>,
local_time: Timestamp
) -> bool
pub fn vote_leader_timeout( &mut self, chain_id: ChainId, height: BlockHeight, epoch: Epoch, key_pair: Option<&KeyPair>, local_time: Timestamp ) -> bool
Checks if the current round has timed out, and signs a LeaderTimeout
.
sourcepub fn check_validated_block(
&self,
certificate: &Certificate
) -> Result<Outcome, ChainError>
pub fn check_validated_block( &self, certificate: &Certificate ) -> Result<Outcome, ChainError>
Verifies that we can vote to confirm a validated block.
sourcepub fn create_vote(
&mut self,
proposal: BlockProposal,
outcome: BlockExecutionOutcome,
key_pair: Option<&KeyPair>,
local_time: Timestamp
)
pub fn create_vote( &mut self, proposal: BlockProposal, outcome: BlockExecutionOutcome, key_pair: Option<&KeyPair>, local_time: Timestamp )
Signs a vote to validate the proposed block.
sourcepub fn create_final_vote(
&mut self,
certificate: Certificate,
key_pair: Option<&KeyPair>,
local_time: Timestamp
)
pub fn create_final_vote( &mut self, certificate: Certificate, key_pair: Option<&KeyPair>, local_time: Timestamp )
Signs a vote to confirm the validated block.
sourcepub fn handle_timeout_certificate(
&mut self,
certificate: Certificate,
local_time: Timestamp
)
pub fn handle_timeout_certificate( &mut self, certificate: Certificate, local_time: Timestamp )
Updates the round number and timer if the timeout certificate is from a higher round than any known certificate.
sourcepub fn verify_owner(&self, proposal: &BlockProposal) -> Option<PublicKey>
pub fn verify_owner(&self, proposal: &BlockProposal) -> Option<PublicKey>
Returns the public key of the block proposal’s signer, if they are a valid owner and allowed to propose a block in the proposal’s round.
Trait Implementations§
source§impl Clone for ChainManager
impl Clone for ChainManager
source§fn clone(&self) -> ChainManager
fn clone(&self) -> ChainManager
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ChainManager
impl Debug for ChainManager
source§impl Default for ChainManager
impl Default for ChainManager
source§fn default() -> ChainManager
fn default() -> ChainManager
source§impl<'de> Deserialize<'de> for ChainManager
impl<'de> Deserialize<'de> for ChainManager
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl From<&ChainManager> for ChainManagerInfo
impl From<&ChainManager> for ChainManagerInfo
source§fn from(manager: &ChainManager) -> Self
fn from(manager: &ChainManager) -> Self
source§impl InputType for ChainManager
impl InputType for ChainManager
§type RawValueType = ChainManager
type RawValueType = ChainManager
source§fn create_type_info(registry: &mut Registry) -> String
fn create_type_info(registry: &mut Registry) -> String
source§fn parse(value: Option<Value>) -> InputValueResult<Self>
fn parse(value: Option<Value>) -> InputValueResult<Self>
Value
. None represents undefined.source§fn as_raw_value(&self) -> Option<&Self::RawValueType>
fn as_raw_value(&self) -> Option<&Self::RawValueType>
source§fn qualified_type_name() -> String
fn qualified_type_name() -> String
source§impl OutputType for ChainManager
impl OutputType for ChainManager
source§fn create_type_info(registry: &mut Registry) -> String
fn create_type_info(registry: &mut Registry) -> String
source§async fn resolve(
&self,
_: &ContextSelectionSet<'_>,
_field: &Positioned<Field>
) -> ServerResult<Value>
async fn resolve( &self, _: &ContextSelectionSet<'_>, _field: &Positioned<Field> ) -> ServerResult<Value>
async_graphql::Value
.