[−][src]Struct exonum::blockchain::config::ConsensusConfig
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)
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]
&self,
predicate: impl Fn(&ValidatorKeys) -> bool
) -> Option<ValidatorId>
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]
fn to_bytes(&self) -> Vec<u8>
[src]
fn from_bytes(value: Cow<[u8]>) -> Result<Self, Error>
[src]
fn into_bytes(self) -> Vec<u8>
[src]
impl Clone for ConsensusConfig
[src]
fn clone(&self) -> ConsensusConfig
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for ConsensusConfig
[src]
impl Default for ConsensusConfig
[src]
impl<'de> Deserialize<'de> for ConsensusConfig
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl Eq for ConsensusConfig
[src]
impl Hash for ConsensusConfig
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl ObjectHash for ConsensusConfig
[src]
fn object_hash(&self) -> Hash
[src]
impl PartialEq<ConsensusConfig> for ConsensusConfig
[src]
fn eq(&self, other: &ConsensusConfig) -> bool
[src]
fn ne(&self, other: &ConsensusConfig) -> bool
[src]
impl ProtobufConvert for ConsensusConfig
[src]
type ProtoStruct = Config
Type generated from the Protobuf definition.
fn from_pb(pb: Self::ProtoStruct) -> Result<Self, Error>
[src]
fn to_pb(&self) -> Self::ProtoStruct
[src]
impl Serialize for ConsensusConfig
[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl StructuralEq for ConsensusConfig
[src]
impl StructuralPartialEq for ConsensusConfig
[src]
impl ValidateInput for ConsensusConfig
[src]
Auto Trait Implementations
impl RefUnwindSafe for ConsensusConfig
impl Send for ConsensusConfig
impl Sync for ConsensusConfig
impl Unpin for ConsensusConfig
impl UnwindSafe for ConsensusConfig
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Clear for T where
T: InitializableFromZeroed + ?Sized,
T: InitializableFromZeroed + ?Sized,
fn clear(&mut self)
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T> InitializableFromZeroed for T where
T: Default,
T: Default,
unsafe fn initialize(place: *mut T)
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,