Add registrar fields (#4716)
* add registrar field * use constructor for dev registrar * fix test
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
//! Authority params deserialization.
|
||||
|
||||
use uint::Uint;
|
||||
use hash::Address;
|
||||
use super::ValidatorSet;
|
||||
|
||||
/// Authority params deserialization.
|
||||
@@ -33,6 +34,8 @@ pub struct AuthorityRoundParams {
|
||||
/// Block reward.
|
||||
#[serde(rename="blockReward")]
|
||||
pub block_reward: Option<Uint>,
|
||||
/// Address of the registrar contract.
|
||||
pub registrar: Option<Address>,
|
||||
/// Starting step. Determined automatically if not specified.
|
||||
/// To be used for testing only.
|
||||
#[serde(rename="startStep")]
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
//! Engine deserialization.
|
||||
|
||||
use super::{Ethash, BasicAuthority, AuthorityRound, Tendermint};
|
||||
use super::{Ethash, InstantSeal, BasicAuthority, AuthorityRound, Tendermint};
|
||||
|
||||
/// Engine deserialization.
|
||||
#[derive(Debug, PartialEq, Deserialize)]
|
||||
@@ -26,7 +26,7 @@ pub enum Engine {
|
||||
Null,
|
||||
/// Instantly sealing engine.
|
||||
#[serde(rename="instantSeal")]
|
||||
InstantSeal,
|
||||
InstantSeal(InstantSeal),
|
||||
/// Ethash engine.
|
||||
Ethash(Ethash),
|
||||
/// BasicAuthority engine.
|
||||
@@ -55,12 +55,10 @@ mod tests {
|
||||
assert_eq!(Engine::Null, deserialized);
|
||||
|
||||
let s = r#"{
|
||||
"instantSeal": null
|
||||
"instantSeal": { "params": {} }
|
||||
}"#;
|
||||
|
||||
let deserialized: Engine = serde_json::from_str(s).unwrap();
|
||||
assert_eq!(Engine::InstantSeal, deserialized);
|
||||
|
||||
let _deserialized: Engine = serde_json::from_str(s).unwrap();
|
||||
|
||||
let s = r#"{
|
||||
"Ethash": {
|
||||
|
||||
50
json/src/spec/instant_seal.rs
Normal file
50
json/src/spec/instant_seal.rs
Normal file
@@ -0,0 +1,50 @@
|
||||
// Copyright 2015-2017 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 params deserialization.
|
||||
|
||||
use hash::Address;
|
||||
|
||||
/// Instant params deserialization.
|
||||
#[derive(Debug, PartialEq, Deserialize)]
|
||||
pub struct InstantSealParams {
|
||||
/// Address of the registrar contract.
|
||||
pub registrar: Option<Address>,
|
||||
}
|
||||
|
||||
/// Instant engine deserialization.
|
||||
#[derive(Debug, PartialEq, Deserialize)]
|
||||
pub struct InstantSeal {
|
||||
/// Instant Seal params.
|
||||
pub params: InstantSealParams,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use serde_json;
|
||||
use spec::instant_seal::InstantSeal;
|
||||
|
||||
#[test]
|
||||
fn instant_seal_deserialization() {
|
||||
let s = r#"{
|
||||
"params": {
|
||||
"registrar": "0xc6d9d2cd449a754c494264e1809c50e34d64562b"
|
||||
}
|
||||
}"#;
|
||||
|
||||
let _deserialized: InstantSeal = serde_json::from_str(s).unwrap();
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,7 @@ pub mod engine;
|
||||
pub mod state;
|
||||
pub mod ethash;
|
||||
pub mod validator_set;
|
||||
pub mod instant_seal;
|
||||
pub mod basic_authority;
|
||||
pub mod authority_round;
|
||||
pub mod tendermint;
|
||||
@@ -40,6 +41,7 @@ pub use self::engine::Engine;
|
||||
pub use self::state::State;
|
||||
pub use self::ethash::{Ethash, EthashParams};
|
||||
pub use self::validator_set::ValidatorSet;
|
||||
pub use self::instant_seal::{InstantSeal, InstantSealParams};
|
||||
pub use self::basic_authority::{BasicAuthority, BasicAuthorityParams};
|
||||
pub use self::authority_round::{AuthorityRound, AuthorityRoundParams};
|
||||
pub use self::tendermint::{Tendermint, TendermintParams};
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
//! Tendermint params deserialization.
|
||||
|
||||
use uint::Uint;
|
||||
use hash::Address;
|
||||
use super::ValidatorSet;
|
||||
|
||||
/// Tendermint params deserialization.
|
||||
@@ -42,6 +43,8 @@ pub struct TendermintParams {
|
||||
/// Block reward.
|
||||
#[serde(rename="blockReward")]
|
||||
pub block_reward: Option<Uint>,
|
||||
/// Address of the registrar contract.
|
||||
pub registrar: Option<Address>,
|
||||
}
|
||||
|
||||
/// Tendermint engine deserialization.
|
||||
|
||||
Reference in New Issue
Block a user