Trait tendermint_machine::ext::Network
source · pub trait Network: Sized + Send + Sync {
type Db: Db;
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,
slash_event: SlashEvent,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn validate<'life0, 'life1, 'async_trait>(
&'life0 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 = Option<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 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§
sourceconst BLOCK_PROCESSING_TIME: u32
const BLOCK_PROCESSING_TIME: u32
Maximum block processing time in milliseconds.
This should include both the time to download the block and the actual processing time.
BLOCK_PROCESSING_TIME + (3 * LATENCY_TIME) must be divisible by 1000.
sourceconst LATENCY_TIME: u32
const LATENCY_TIME: u32
Network latency time in milliseconds.
BLOCK_PROCESSING_TIME + (3 * LATENCY_TIME) must be divisible by 1000.
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,
slash_event: SlashEvent,
) -> 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,
slash_event: SlashEvent,
) -> 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 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 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 = Option<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 = Option<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, in seconds. 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.