[][src]Struct exonum::blockchain::config::ConsensusConfig

#[non_exhaustive]pub struct ConsensusConfig {
    pub validator_keys: Vec<ValidatorKeys>,
    pub first_round_timeout: Milliseconds,
    pub status_timeout: Milliseconds,
    pub peers_timeout: Milliseconds,
    pub txs_block_limit: u32,
    pub max_message_len: u32,
    pub min_propose_timeout: Milliseconds,
    pub max_propose_timeout: Milliseconds,
    pub propose_timeout_threshold: u32,
}

Consensus algorithm parameters.

This configuration is initially created with default recommended values, which can later be edited as required. The parameters in this configuration should be the same for all nodes in the network and can be changed using the configuration update service.

Default propose timeout value, along with the threshold, is chosen for maximal performance. In order to slow down block generation,hence consume less disk space, these values can be increased.

For additional information on the Exonum consensus algorithm, refer to Consensus in Exonum.

Fields (Non-exhaustive)

Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
validator_keys: Vec<ValidatorKeys>

List of validators public keys.

first_round_timeout: Milliseconds

Interval between first two rounds. This interval defines the time that passes between the moment a new block is committed to the blockchain and the time when second round starts, regardless of whether a new block has been committed during this period or not. Each consecutive round will be longer then previous by a constant factor, 10%.

Note that rounds in Exonum do not have a defined end time. Nodes in a new round can continue to vote for proposals and process messages related to previous rounds.

status_timeout: Milliseconds

Period of sending a Status message. This parameter defines the frequency with which a node broadcasts its status message to the network.

peers_timeout: Milliseconds

Peer exchange timeout. This parameter defines the frequency with which a node requests collected Connect messages from a random peer node in the network.

txs_block_limit: u32

Maximum number of transactions per block.

max_message_len: u32

Maximum message length (in bytes). This parameter determines the maximum size of both consensus messages and transactions. The default value of the parameter is 1 MB (1024 * 1024 bytes). The range of possible values for this parameter is between 1MB and 2^32-1 bytes.

min_propose_timeout: Milliseconds

Minimal propose timeout.

max_propose_timeout: Milliseconds

Maximal propose timeout.

propose_timeout_threshold: u32

Amount of transactions in pool to start use min_propose_timeout.

Default value is equal to half of the txs_block_limit in order to gather more transactions in a block if the transaction pool is almost empty, and create blocks faster when there are enough transactions in the pool.

Methods

impl ConsensusConfig[src]

pub const DEFAULT_MAX_MESSAGE_LEN: u32[src]

Default value for max_message_len.

pub const TIMEOUT_LINEAR_INCREASE_PERCENT: u64[src]

Time that will be added to round timeout for each next round in terms of percent of first_round_timeout.

pub fn with_validator_keys(self, validator_keys: Vec<ValidatorKeys>) -> Self[src]

Replaces validator keys in existing object with provided ones.

pub fn for_tests(validator_count: u16) -> (Self, Keys)[src]

Generates a consensus configuration for testing and returns it together with the keys for the first validator.

pub fn find_validator(
    &self,
    predicate: impl Fn(&ValidatorKeys) -> bool
) -> Option<ValidatorId>
[src]

Search for identifier of the validator which satisfies the condition in predicate.

Examples

use exonum::{
    blockchain::{ConsensusConfig, ValidatorKeys},
    crypto,
    helpers::ValidatorId,
};

let config = ConsensusConfig::default()
    .with_validator_keys(
        (0..4)
            .map(|_| ValidatorKeys::new(
                crypto::gen_keypair().0,
                crypto::gen_keypair().0,
            ))
            .collect(),
    );

let some_validator_consensus_key = config.validator_keys[2].consensus_key;
// Try to find validator ID for this key.
assert_eq!(
    config.find_validator(|validator_keys| {
        validator_keys.consensus_key == some_validator_consensus_key
    }),
    Some(ValidatorId(2)),
);

Trait Implementations

impl BinaryValue for ConsensusConfig[src]

impl Clone for ConsensusConfig[src]

impl Debug for ConsensusConfig[src]

impl Default for ConsensusConfig[src]

impl<'de> Deserialize<'de> for ConsensusConfig[src]

impl Eq for ConsensusConfig[src]

impl Hash for ConsensusConfig[src]

impl ObjectHash for ConsensusConfig[src]

impl PartialEq<ConsensusConfig> for ConsensusConfig[src]

impl ProtobufConvert for ConsensusConfig[src]

type ProtoStruct = Config

Type generated from the Protobuf definition.

impl Serialize for ConsensusConfig[src]

impl StructuralEq for ConsensusConfig[src]

impl StructuralPartialEq for ConsensusConfig[src]

impl ValidateInput for ConsensusConfig[src]

type Error = Error

The type returned in the event of a validate error.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Clear for T where
    T: InitializableFromZeroed + ?Sized

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T> InitializableFromZeroed for T where
    T: Default

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,