parent
c8ae675b95
commit
6b286a5dee
@ -18,7 +18,7 @@ use engines::{Engine, Seal};
|
||||
use parity_machine::{Machine, Transactions, TotalScoredHeader};
|
||||
|
||||
/// `InstantSeal` params.
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Default, Debug, PartialEq)]
|
||||
pub struct InstantSealParams {
|
||||
/// Whether to use millisecond timestamp
|
||||
pub millisecond_timestamp: bool,
|
||||
|
@ -32,7 +32,7 @@ pub mod epoch;
|
||||
pub use self::authority_round::AuthorityRound;
|
||||
pub use self::basic_authority::BasicAuthority;
|
||||
pub use self::epoch::{EpochVerifier, Transition as EpochTransition};
|
||||
pub use self::instant_seal::InstantSeal;
|
||||
pub use self::instant_seal::{InstantSeal, InstantSealParams};
|
||||
pub use self::null_engine::NullEngine;
|
||||
pub use self::tendermint::Tendermint;
|
||||
|
||||
|
@ -33,7 +33,10 @@ use vm::{EnvInfo, CallType, ActionValue, ActionParams, ParamsType};
|
||||
|
||||
use builtin::Builtin;
|
||||
use encoded;
|
||||
use engines::{EthEngine, NullEngine, InstantSeal, BasicAuthority, AuthorityRound, Tendermint, DEFAULT_BLOCKHASH_CONTRACT};
|
||||
use engines::{
|
||||
EthEngine, NullEngine, InstantSeal, InstantSealParams, BasicAuthority,
|
||||
AuthorityRound, Tendermint, DEFAULT_BLOCKHASH_CONTRACT
|
||||
};
|
||||
use error::Error;
|
||||
use executive::Executive;
|
||||
use factory::Factories;
|
||||
@ -596,7 +599,8 @@ impl Spec {
|
||||
match engine_spec {
|
||||
ethjson::spec::Engine::Null(null) => Arc::new(NullEngine::new(null.params.into(), machine)),
|
||||
ethjson::spec::Engine::Ethash(ethash) => Arc::new(::ethereum::Ethash::new(spec_params.cache_dir, ethash.params.into(), machine, spec_params.optimization_setting)),
|
||||
ethjson::spec::Engine::InstantSeal(instant_seal) => Arc::new(InstantSeal::new(instant_seal.params.into(), machine)),
|
||||
ethjson::spec::Engine::InstantSeal(Some(instant_seal)) => Arc::new(InstantSeal::new(instant_seal.params.into(), machine)),
|
||||
ethjson::spec::Engine::InstantSeal(None) => Arc::new(InstantSeal::new(InstantSealParams::default(), machine)),
|
||||
ethjson::spec::Engine::BasicAuthority(basic_authority) => Arc::new(BasicAuthority::new(basic_authority.params.into(), machine)),
|
||||
ethjson::spec::Engine::AuthorityRound(authority_round) => AuthorityRound::new(authority_round.params.into(), machine)
|
||||
.expect("Failed to start AuthorityRound consensus engine."),
|
||||
|
@ -26,7 +26,7 @@ pub enum Engine {
|
||||
Null(NullEngine),
|
||||
/// Instantly sealing engine.
|
||||
#[serde(rename="instantSeal")]
|
||||
InstantSeal(InstantSeal),
|
||||
InstantSeal(Option<InstantSeal>),
|
||||
/// Ethash engine.
|
||||
Ethash(Ethash),
|
||||
/// BasicAuthority engine.
|
||||
@ -71,6 +71,17 @@ mod tests {
|
||||
_ => panic!(),
|
||||
};
|
||||
|
||||
let s = r#"{
|
||||
"instantSeal": null
|
||||
}"#;
|
||||
|
||||
let deserialized: Engine = serde_json::from_str(s).unwrap();
|
||||
match deserialized {
|
||||
Engine::InstantSeal(_) => {}, // instant seal is unit tested in its own file.
|
||||
_ => panic!(),
|
||||
};
|
||||
|
||||
|
||||
let s = r#"{
|
||||
"Ethash": {
|
||||
"params": {
|
||||
|
Loading…
Reference in New Issue
Block a user