Trait tendermint_machine::ext::Network
source · pub trait Network: Send + Sync {
type ValidatorId: ValidatorId;
type SignatureScheme: SignatureScheme<ValidatorId = Self::ValidatorId>;
type Weights: Weights<ValidatorId = Self::ValidatorId>;
type Block: Block;
const BLOCK_TIME: u32;
fn signer(&self) -> <Self::SignatureScheme as SignatureScheme>::Signer;
fn signature_scheme(&self) -> Self::SignatureScheme;
fn weights(&self) -> Self::Weights;
fn broadcast<'life0, 'async_trait>(
&'life0 mut self,
msg: SignedMessage<Self::ValidatorId, Self::Block, <Self::SignatureScheme as SignatureScheme>::Signature>
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait;
fn slash<'life0, 'async_trait>(
&'life0 mut self,
validator: Self::ValidatorId
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait;
fn validate<'life0, 'life1, 'async_trait>(
&'life0 mut self,
block: &'life1 Self::Block
) -> Pin<Box<dyn Future<Output = Result<(), BlockError>> + Send + 'async_trait>>
where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait;
fn add_block<'life0, 'async_trait>(
&'life0 mut self,
block: Self::Block,
commit: Commit<Self::SignatureScheme>
) -> Pin<Box<dyn Future<Output = Self::Block> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait;
fn verify_commit(
&self,
id: <Self::Block as Block>::Id,
commit: &Commit<Self::SignatureScheme>
) -> bool { ... }
}Expand description
Trait representing the distributed system Tendermint is providing consensus over.
Required Associated Types
type ValidatorId: ValidatorId
sourcetype SignatureScheme: SignatureScheme<ValidatorId = Self::ValidatorId>
type SignatureScheme: SignatureScheme<ValidatorId = Self::ValidatorId>
Signature scheme used by validators.
sourcetype Weights: Weights<ValidatorId = Self::ValidatorId>
type Weights: Weights<ValidatorId = Self::ValidatorId>
Object representing the weights of validators.
Required Associated Constants
const BLOCK_TIME: u32
Required Methods
sourcefn signer(&self) -> <Self::SignatureScheme as SignatureScheme>::Signer
fn signer(&self) -> <Self::SignatureScheme as SignatureScheme>::Signer
Return a handle on the signer in use, usable for the entire lifetime of the machine.
sourcefn signature_scheme(&self) -> Self::SignatureScheme
fn signature_scheme(&self) -> Self::SignatureScheme
Return a handle on the signing scheme in use, usable for the entire lifetime of the machine.
sourcefn weights(&self) -> Self::Weights
fn weights(&self) -> Self::Weights
Return a handle on the validators’ weights, usable for the entire lifetime of the machine.
sourcefn broadcast<'life0, 'async_trait>(
&'life0 mut self,
msg: SignedMessage<Self::ValidatorId, Self::Block, <Self::SignatureScheme as SignatureScheme>::Signature>
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn broadcast<'life0, 'async_trait>(
&'life0 mut self,
msg: SignedMessage<Self::ValidatorId, Self::Block, <Self::SignatureScheme as SignatureScheme>::Signature>
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Broadcast a message to the other validators. If authenticated channels have already been established, this will double-authenticate. Switching to unauthenticated channels in a system already providing authenticated channels is not recommended as this is a minor, temporal inefficiency while downgrading channels may have wider implications.
sourcefn slash<'life0, 'async_trait>(
&'life0 mut self,
validator: Self::ValidatorId
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn slash<'life0, 'async_trait>(
&'life0 mut self,
validator: Self::ValidatorId
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Trigger a slash for the validator in question who was definitively malicious. The exact process of triggering a slash is undefined and left to the network as a whole.
sourcefn validate<'life0, 'life1, 'async_trait>(
&'life0 mut self,
block: &'life1 Self::Block
) -> Pin<Box<dyn Future<Output = Result<(), BlockError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn validate<'life0, 'life1, 'async_trait>(
&'life0 mut self,
block: &'life1 Self::Block
) -> Pin<Box<dyn Future<Output = Result<(), BlockError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Validate a block.
sourcefn add_block<'life0, 'async_trait>(
&'life0 mut self,
block: Self::Block,
commit: Commit<Self::SignatureScheme>
) -> Pin<Box<dyn Future<Output = Self::Block> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn add_block<'life0, 'async_trait>(
&'life0 mut self,
block: Self::Block,
commit: Commit<Self::SignatureScheme>
) -> Pin<Box<dyn Future<Output = Self::Block> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Add a block, returning the proposal for the next one. It’s possible a block, which was never validated or even failed validation, may be passed here if a supermajority of validators did consider it valid and created a commit for it. This deviates from the paper which will have a local node refuse to decide on a block it considers invalid. This library acknowledges the network did decide on it, leaving handling of it to the network, and outside of this scope.
Provided Methods
sourcefn verify_commit(
&self,
id: <Self::Block as Block>::Id,
commit: &Commit<Self::SignatureScheme>
) -> bool
fn verify_commit(
&self,
id: <Self::Block as Block>::Id,
commit: &Commit<Self::SignatureScheme>
) -> bool
Verify a commit for a given block. Intended for use when syncing or when not an active validator.