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_PROCESSING_TIME: u32;
const LATENCY_TIME: u32;
// Required methods
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: SignedMessageFor<Self>,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn slash<'life0, 'async_trait>(
&'life0 mut self,
validator: Self::ValidatorId,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: '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 Self: 'async_trait,
'life0: 'async_trait,
'life1: '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 Self: 'async_trait,
'life0: 'async_trait;
// Provided methods
fn block_time() -> u32 { ... }
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 Constants§
Sourceconst BLOCK_PROCESSING_TIME: u32
const BLOCK_PROCESSING_TIME: u32
Maximum block processing time in seconds. This should include both the actual processing time and the time to download the block.
Sourceconst LATENCY_TIME: u32
const LATENCY_TIME: u32
Network latency time in seconds.
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 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: SignedMessageFor<Self>,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn broadcast<'life0, 'async_trait>(
&'life0 mut self,
msg: SignedMessageFor<Self>,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: '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
Self: 'async_trait,
'life0: 'async_trait,
fn slash<'life0, 'async_trait>(
&'life0 mut self,
validator: Self::ValidatorId,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: '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
Self: 'async_trait,
'life0: 'async_trait,
'life1: '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
Self: 'async_trait,
'life0: 'async_trait,
'life1: '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
Self: 'async_trait,
'life0: '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
Self: 'async_trait,
'life0: '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 block_time() -> u32
fn block_time() -> u32
The block time is defined as the processing time plus three times the latency.
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.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".