diff --git a/ethcore/src/engines/tendermint/mod.rs b/ethcore/src/engines/tendermint/mod.rs index 4ebaca347..e6ee0f387 100644 --- a/ethcore/src/engines/tendermint/mod.rs +++ b/ethcore/src/engines/tendermint/mod.rs @@ -18,6 +18,7 @@ mod message; mod timeout; +mod params; use std::sync::atomic::{AtomicUsize, Ordering as AtomicOrdering}; use common::*; @@ -28,36 +29,10 @@ use block::*; use spec::CommonParams; use engines::{Engine, EngineError, ProposeCollect}; use evm::Schedule; -use ethjson; use io::IoService; use self::message::ConsensusMessage; -use self::timeout::{TimerHandler, NextStep, DefaultTimeouts}; - -/// `Tendermint` params. -#[derive(Debug, Clone)] -pub struct TendermintParams { - /// Gas limit divisor. - pub gas_limit_bound_divisor: U256, - /// List of validators. - pub validators: Vec
, - /// Number of validators. - pub validator_n: usize, - /// Timeout durations for different steps. - timeouts: DefaultTimeouts, -} - -impl Default for TendermintParams { - fn default() -> Self { - let validators = vec!["0x7d577a597b2742b498cb5cf0c26cdcd726d39e6e".into(), "0x82a978b3f5962a5b0957d9ee9eef472ee55b42f1".into()]; - let val_n = validators.len(); - TendermintParams { - gas_limit_bound_divisor: 0x0400.into(), - validators: validators, - validator_n: val_n, - timeouts: DefaultTimeouts::default() - } - } -} +use self::timeout::{TimerHandler, NextStep}; +use self::params::TendermintParams; #[derive(Debug)] enum Step { @@ -76,19 +51,6 @@ pub type BlockHash = H256; pub type AtomicMs = AtomicUsize; type Seal = Vec; -impl From for TendermintParams { - fn from(p: ethjson::spec::TendermintParams) -> Self { - let val: Vec<_> = p.validators.into_iter().map(Into::into).collect(); - let val_n = val.len(); - TendermintParams { - gas_limit_bound_divisor: p.gas_limit_bound_divisor.into(), - validators: val, - validator_n: val_n, - timeouts: DefaultTimeouts::default() - } - } -} - /// Engine using `Tendermint` consensus algorithm, suitable for EVM chain. pub struct Tendermint { params: CommonParams, diff --git a/ethcore/src/engines/tendermint/params.rs b/ethcore/src/engines/tendermint/params.rs new file mode 100644 index 000000000..2a23cbb27 --- /dev/null +++ b/ethcore/src/engines/tendermint/params.rs @@ -0,0 +1,60 @@ +// Copyright 2015, 2016 Ethcore (UK) Ltd. +// This file is part of Parity. + +// Parity is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Parity is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Parity. If not, see . + +//! Tendermint BFT consensus engine with round robin proof-of-authority. + +use common::{Address, U256}; +use ethjson; +use super::timeout::DefaultTimeouts; + +/// `Tendermint` params. +#[derive(Debug, Clone)] +pub struct TendermintParams { + /// Gas limit divisor. + pub gas_limit_bound_divisor: U256, + /// List of validators. + pub validators: Vec
, + /// Number of validators. + pub validator_n: usize, + /// Timeout durations for different steps. + pub timeouts: DefaultTimeouts, +} + +impl Default for TendermintParams { + fn default() -> Self { + let validators = vec!["0x7d577a597b2742b498cb5cf0c26cdcd726d39e6e".into(), "0x82a978b3f5962a5b0957d9ee9eef472ee55b42f1".into()]; + let val_n = validators.len(); + TendermintParams { + gas_limit_bound_divisor: 0x0400.into(), + validators: validators, + validator_n: val_n, + timeouts: DefaultTimeouts::default() + } + } +} + +impl From for TendermintParams { + fn from(p: ethjson::spec::TendermintParams) -> Self { + let val: Vec<_> = p.validators.into_iter().map(Into::into).collect(); + let val_n = val.len(); + TendermintParams { + gas_limit_bound_divisor: p.gas_limit_bound_divisor.into(), + validators: val, + validator_n: val_n, + timeouts: DefaultTimeouts::default() + } + } +}