Skip to main content

Network

Trait Network 

Source
pub trait Network<V: Validator, S: Signature, A: AggregateSignature, B: Block> {
    type Sleep: Future<Output = ()>;

    const LATENCY_TIME: Duration;
    const BLOCK_DOWNLOADING_TIME: Duration;
    const BLOCK_PROCESSING_TIME: Duration;

    // Required methods
    fn sleep(duration: Duration) -> Self::Sleep;
    fn broadcast(
        &mut self,
        message: Message<V, S, A, B>,
    ) -> impl Send + Future<Output = ()>;
}
Expand description

A view over the network used for consensus.

Required Associated Constants§

Source

const LATENCY_TIME: Duration

The expected average-case latency of the network.

This should be sufficient for a supermajority of validators to communicate, in the average case, as necessary to perform the consensus protocol. If the real-world latency exceeds this amount of time, the attempt to finalize a block will fail, and a new round will begin with an increased amount of latency. Accordingly, setting this to too optimistic of a value will increase the amount of failures.

The derivatives of this MAY be limited to the bounds of the internal representations used for time.

Source

const BLOCK_DOWNLOADING_TIME: Duration

The expected maximum amount of time to download a block.

The derivatives of this MAY be limited to the bounds of the internal representations used for time.

Source

const BLOCK_PROCESSING_TIME: Duration

The expected maximum amount of time to process a block.

This is also used as a timeout for fetching the block proposal, if it isn’t ready yet.

The derivatives of this MAY be limited to the bounds of the internal representations used for time.

Required Associated Types§

Source

type Sleep: Future<Output = ()>

The future returned by Network::sleep.

Required Methods§

Source

fn sleep(duration: Duration) -> Self::Sleep

An asynchronous implementation of std::thread::sleep.

This MUST be cancel-safe.

Source

fn broadcast( &mut self, message: Message<V, S, A, B>, ) -> impl Send + Future<Output = ()>

Broadcast a message to the other validators.

Examples of broadcast include sending this message via peer-to-peer channels to all other validators, or publishing this message to a gossip network where it can be reasonably assumed to be delivered to all other validators. It does not have to achieve a formal definition of broadcast with any specific security properties, though failure for this message to be delivered to a sufficient amount of other validators in a timely fashion will cause consensus to stall until the timeout for a round exceeds the latency of this network.

This DOES NOT have to be cancel-safe.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§