// 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 .
//! Parameters for a block chain.
use common::*;
use engines::{Engine, NullEngine, InstantSeal, BasicAuthority};
use pod_state::*;
use account_db::*;
use super::genesis::Genesis;
use super::seal::Generic as GenericSeal;
use ethereum;
use ethjson;
use rlp::{Rlp, RlpStream, View, Stream};
/// Parameters common to all engines.
#[derive(Debug, PartialEq, Clone)]
#[cfg_attr(test, derive(Default))]
pub struct CommonParams {
/// Account start nonce.
pub account_start_nonce: U256,
/// Maximum size of extra data.
pub maximum_extra_data_size: usize,
/// Network id.
pub network_id: U256,
/// Minimum gas limit.
pub min_gas_limit: U256,
/// Fork block to check.
pub fork_block: Option<(BlockNumber, H256)>,
}
impl From for CommonParams {
fn from(p: ethjson::spec::Params) -> Self {
CommonParams {
account_start_nonce: p.account_start_nonce.into(),
maximum_extra_data_size: p.maximum_extra_data_size.into(),
network_id: p.network_id.into(),
min_gas_limit: p.min_gas_limit.into(),
fork_block: if let (Some(n), Some(h)) = (p.fork_block, p.fork_hash) { Some((n.into(), h.into())) } else { None },
}
}
}
/// Parameters for a block chain; includes both those intrinsic to the design of the
/// chain and those to be interpreted by the active chain engine.
pub struct Spec {
/// User friendly spec name
pub name: String,
/// What engine are we using for this?
pub engine: Arc,
/// The fork identifier for this chain. Only needed to distinguish two chains sharing the same genesis.
pub fork_name: Option,
/// Known nodes on the network in enode format.
pub nodes: Vec,
/// Parameters common to all engines.
pub params: CommonParams,
/// The genesis block's parent hash field.
pub parent_hash: H256,
/// The genesis block's author field.
pub author: Address,
/// The genesis block's difficulty field.
pub difficulty: U256,
/// The genesis block's gas limit field.
pub gas_limit: U256,
/// The genesis block's gas used field.
pub gas_used: U256,
/// The genesis block's timestamp field.
pub timestamp: u64,
/// Transactions root of the genesis block. Should be SHA3_NULL_RLP.
pub transactions_root: H256,
/// Receipts root of the genesis block. Should be SHA3_NULL_RLP.
pub receipts_root: H256,
/// The genesis block's extra data field.
pub extra_data: Bytes,
/// The number of seal fields in the genesis block.
pub seal_fields: usize,
/// Each seal field, expressed as RLP, concatenated.
pub seal_rlp: Bytes,
// May be prepopulated if we know this in advance.
state_root_memo: RwLock