Add registrar fields (#4716)

* add registrar field

* use constructor for dev registrar

* fix test
This commit is contained in:
keorn
2017-03-02 12:25:55 +01:00
committed by Gav Wood
parent 5dd406a19a
commit ade5a13f5b
11 changed files with 100 additions and 12 deletions

View File

@@ -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")]

View File

@@ -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": {

View 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();
}
}

View File

@@ -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};

View File

@@ -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.