Support millisecond timestamp for instant seal engine (#9469)
* Support millisecond timestamp for instant seal engine * Forgot to checkin instant_seal mod * Fix instant seal config * Fix json crate compile * Fix private_spec.json * Option<bool> -> bool
This commit is contained in:
committed by
Andronik Ordian
parent
39a12622ae
commit
5752869824
@@ -16,7 +16,7 @@
|
||||
|
||||
//! Engine deserialization.
|
||||
|
||||
use super::{Ethash, BasicAuthority, AuthorityRound, Tendermint, NullEngine};
|
||||
use super::{Ethash, BasicAuthority, AuthorityRound, Tendermint, NullEngine, InstantSeal};
|
||||
|
||||
/// Engine deserialization.
|
||||
#[derive(Debug, PartialEq, Deserialize)]
|
||||
@@ -26,7 +26,7 @@ pub enum Engine {
|
||||
Null(NullEngine),
|
||||
/// Instantly sealing engine.
|
||||
#[serde(rename="instantSeal")]
|
||||
InstantSeal,
|
||||
InstantSeal(InstantSeal),
|
||||
/// Ethash engine.
|
||||
Ethash(Ethash),
|
||||
/// BasicAuthority engine.
|
||||
@@ -62,12 +62,12 @@ mod tests {
|
||||
}
|
||||
|
||||
let s = r#"{
|
||||
"instantSeal": null
|
||||
"instantSeal": {"params": {}}
|
||||
}"#;
|
||||
|
||||
let deserialized: Engine = serde_json::from_str(s).unwrap();
|
||||
match deserialized {
|
||||
Engine::InstantSeal => {}, // instant seal is unit tested in its own file.
|
||||
Engine::InstantSeal(_) => {}, // instant seal is unit tested in its own file.
|
||||
_ => panic!(),
|
||||
};
|
||||
|
||||
|
||||
33
json/src/spec/instant_seal.rs
Normal file
33
json/src/spec/instant_seal.rs
Normal file
@@ -0,0 +1,33 @@
|
||||
// Copyright 2015-2018 Parity Technologies (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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Instant seal engine params deserialization.
|
||||
|
||||
/// Instant seal engine params deserialization.
|
||||
#[derive(Debug, PartialEq, Deserialize)]
|
||||
pub struct InstantSealParams {
|
||||
/// Whether to enable millisecond timestamp.
|
||||
#[serde(rename="millisecondTimestamp")]
|
||||
#[serde(default)]
|
||||
pub millisecond_timestamp: bool,
|
||||
}
|
||||
|
||||
/// Instant seal engine descriptor.
|
||||
#[derive(Debug, PartialEq, Deserialize)]
|
||||
pub struct InstantSeal {
|
||||
/// Instant seal parameters.
|
||||
pub params: InstantSealParams,
|
||||
}
|
||||
@@ -30,6 +30,7 @@ pub mod basic_authority;
|
||||
pub mod authority_round;
|
||||
pub mod tendermint;
|
||||
pub mod null_engine;
|
||||
pub mod instant_seal;
|
||||
pub mod hardcoded_sync;
|
||||
|
||||
pub use self::account::Account;
|
||||
@@ -46,4 +47,5 @@ pub use self::basic_authority::{BasicAuthority, BasicAuthorityParams};
|
||||
pub use self::authority_round::{AuthorityRound, AuthorityRoundParams};
|
||||
pub use self::tendermint::{Tendermint, TendermintParams};
|
||||
pub use self::null_engine::{NullEngine, NullEngineParams};
|
||||
pub use self::instant_seal::{InstantSeal, InstantSealParams};
|
||||
pub use self::hardcoded_sync::HardcodedSync;
|
||||
|
||||
Reference in New Issue
Block a user