Skip to main content

Network

Trait 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_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§

Source

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.

Source

const LATENCY_TIME: u32

Network latency time in seconds.

Required Associated Types§

Source

type ValidatorId: ValidatorId

Source

type SignatureScheme: SignatureScheme<ValidatorId = Self::ValidatorId>

Signature scheme used by validators.

Source

type Weights: Weights<ValidatorId = Self::ValidatorId>

Object representing the weights of validators.

Source

type Block: Block

Type used for ordered blocks of information.

Required Methods§

Source

fn signer(&self) -> <Self::SignatureScheme as SignatureScheme>::Signer

Return a handle on the signer in use, usable for the entire lifetime of the machine.

Source

fn signature_scheme(&self) -> Self::SignatureScheme

Return a handle on the signing scheme in use, usable for the entire lifetime of the machine.

Source

fn weights(&self) -> Self::Weights

Return a handle on the validators’ weights, usable for the entire lifetime of the machine.

Source

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.

Source

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.

Source

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.

Source

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§

Source

fn block_time() -> u32

The block time is defined as the processing time plus three times the latency.

Source

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".

Implementors§