Collect consensus/null engines into a single module (#1754)
* collect consesnsus engine code into module * move Engine to mod * fix json test
This commit is contained in:
parent
b62a5c8f7d
commit
11cb544c24
@ -17,7 +17,7 @@
|
|||||||
//! Blockchain block.
|
//! Blockchain block.
|
||||||
|
|
||||||
use common::*;
|
use common::*;
|
||||||
use engine::*;
|
use engines::Engine;
|
||||||
use state::*;
|
use state::*;
|
||||||
use verification::PreverifiedBlock;
|
use verification::PreverifiedBlock;
|
||||||
use trace::FlatTrace;
|
use trace::FlatTrace;
|
||||||
|
@ -22,7 +22,7 @@ use std::sync::{Condvar as SCondvar, Mutex as SMutex};
|
|||||||
use util::*;
|
use util::*;
|
||||||
use verification::*;
|
use verification::*;
|
||||||
use error::*;
|
use error::*;
|
||||||
use engine::Engine;
|
use engines::Engine;
|
||||||
use views::*;
|
use views::*;
|
||||||
use header::*;
|
use header::*;
|
||||||
use service::*;
|
use service::*;
|
||||||
|
@ -40,7 +40,7 @@ use header::BlockNumber;
|
|||||||
use state::State;
|
use state::State;
|
||||||
use spec::Spec;
|
use spec::Spec;
|
||||||
use basic_types::Seal;
|
use basic_types::Seal;
|
||||||
use engine::Engine;
|
use engines::Engine;
|
||||||
use views::HeaderView;
|
use views::HeaderView;
|
||||||
use service::ClientIoMessage;
|
use service::ClientIoMessage;
|
||||||
use env_info::LastHashes;
|
use env_info::LastHashes;
|
||||||
|
@ -19,8 +19,8 @@
|
|||||||
use common::*;
|
use common::*;
|
||||||
use account_provider::AccountProvider;
|
use account_provider::AccountProvider;
|
||||||
use block::*;
|
use block::*;
|
||||||
use spec::{CommonParams, Spec};
|
use spec::CommonParams;
|
||||||
use engine::*;
|
use engines::Engine;
|
||||||
use evm::Schedule;
|
use evm::Schedule;
|
||||||
use ethjson;
|
use ethjson;
|
||||||
|
|
||||||
@ -176,16 +176,16 @@ impl Header {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a new test chain spec with `BasicAuthority` consensus engine.
|
|
||||||
pub fn new_test_authority() -> Spec { Spec::load(include_bytes!("../res/test_authority.json")) }
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
|
||||||
use common::*;
|
use common::*;
|
||||||
use block::*;
|
use block::*;
|
||||||
use tests::helpers::*;
|
use tests::helpers::*;
|
||||||
use account_provider::AccountProvider;
|
use account_provider::AccountProvider;
|
||||||
|
use spec::Spec;
|
||||||
|
|
||||||
|
/// Create a new test chain spec with `BasicAuthority` consensus engine.
|
||||||
|
fn new_test_authority() -> Spec { Spec::load(include_bytes!("../../res/test_authority.json")) }
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn has_valid_metadata() {
|
fn has_valid_metadata() {
|
@ -14,7 +14,13 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
//! Consensus engine specification
|
//! Consensus engine specification and basic implementations.
|
||||||
|
|
||||||
|
mod null_engine;
|
||||||
|
mod basic_authority;
|
||||||
|
|
||||||
|
pub use self::null_engine::NullEngine;
|
||||||
|
pub use self::basic_authority::BasicAuthority;
|
||||||
|
|
||||||
use common::*;
|
use common::*;
|
||||||
use account_provider::AccountProvider;
|
use account_provider::AccountProvider;
|
@ -17,12 +17,12 @@
|
|||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use util::hash::Address;
|
use util::hash::Address;
|
||||||
use builtin::Builtin;
|
use builtin::Builtin;
|
||||||
use engine::Engine;
|
use engines::Engine;
|
||||||
use spec::CommonParams;
|
use spec::CommonParams;
|
||||||
use evm::Schedule;
|
use evm::Schedule;
|
||||||
use env_info::EnvInfo;
|
use env_info::EnvInfo;
|
||||||
|
|
||||||
/// An engine which does not provide any consensus mechanism.
|
/// An engine which does not provide any consensus mechanism and does not seal blocks.
|
||||||
pub struct NullEngine {
|
pub struct NullEngine {
|
||||||
params: CommonParams,
|
params: CommonParams,
|
||||||
builtins: BTreeMap<Address, Builtin>,
|
builtins: BTreeMap<Address, Builtin>,
|
@ -18,7 +18,7 @@ use ethash::{quick_get_difficulty, EthashManager, H256 as EH256};
|
|||||||
use common::*;
|
use common::*;
|
||||||
use block::*;
|
use block::*;
|
||||||
use spec::CommonParams;
|
use spec::CommonParams;
|
||||||
use engine::*;
|
use engines::Engine;
|
||||||
use evm::Schedule;
|
use evm::Schedule;
|
||||||
use ethjson;
|
use ethjson;
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
//! Transaction Execution environment.
|
//! Transaction Execution environment.
|
||||||
use common::*;
|
use common::*;
|
||||||
use state::*;
|
use state::*;
|
||||||
use engine::*;
|
use engines::Engine;
|
||||||
use types::executed::CallType;
|
use types::executed::CallType;
|
||||||
use evm::{self, Ext, Factory, Finalize};
|
use evm::{self, Ext, Factory, Finalize};
|
||||||
use externalities::*;
|
use externalities::*;
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
//! Transaction Execution environment.
|
//! Transaction Execution environment.
|
||||||
use common::*;
|
use common::*;
|
||||||
use state::*;
|
use state::*;
|
||||||
use engine::*;
|
use engines::Engine;
|
||||||
use executive::*;
|
use executive::*;
|
||||||
use evm::{self, Schedule, Ext, ContractCreateResult, MessageCallResult, Factory};
|
use evm::{self, Schedule, Ext, ContractCreateResult, MessageCallResult, Factory};
|
||||||
use substate::*;
|
use substate::*;
|
||||||
@ -300,7 +300,7 @@ impl<'a, T, V> Ext for Externalities<'a, T, V> where T: 'a + Tracer, V: 'a + VMT
|
|||||||
mod tests {
|
mod tests {
|
||||||
use common::*;
|
use common::*;
|
||||||
use state::*;
|
use state::*;
|
||||||
use engine::*;
|
use engines::Engine;
|
||||||
use evm::{Ext};
|
use evm::{Ext};
|
||||||
use substate::*;
|
use substate::*;
|
||||||
use tests::helpers::*;
|
use tests::helpers::*;
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
use super::test_common::*;
|
use super::test_common::*;
|
||||||
use state::*;
|
use state::*;
|
||||||
use executive::*;
|
use executive::*;
|
||||||
use engine::*;
|
use engines::Engine;
|
||||||
use evm;
|
use evm;
|
||||||
use evm::{Schedule, Ext, Factory, Finalize, VMType, ContractCreateResult, MessageCallResult};
|
use evm::{Schedule, Ext, Factory, Finalize, VMType, ContractCreateResult, MessageCallResult};
|
||||||
use externalities::*;
|
use externalities::*;
|
||||||
|
@ -99,7 +99,7 @@ extern crate ethcore_devtools as devtools;
|
|||||||
#[cfg(feature = "jit" )] extern crate evmjit;
|
#[cfg(feature = "jit" )] extern crate evmjit;
|
||||||
|
|
||||||
pub mod account_provider;
|
pub mod account_provider;
|
||||||
pub mod basic_authority;
|
pub mod engines;
|
||||||
pub mod block;
|
pub mod block;
|
||||||
pub mod block_queue;
|
pub mod block_queue;
|
||||||
pub mod client;
|
pub mod client;
|
||||||
@ -111,7 +111,6 @@ pub mod trace;
|
|||||||
pub mod spec;
|
pub mod spec;
|
||||||
pub mod views;
|
pub mod views;
|
||||||
pub mod pod_state;
|
pub mod pod_state;
|
||||||
pub mod engine;
|
|
||||||
pub mod migrations;
|
pub mod migrations;
|
||||||
pub mod miner;
|
pub mod miner;
|
||||||
pub mod snapshot;
|
pub mod snapshot;
|
||||||
@ -127,7 +126,6 @@ mod pod_account;
|
|||||||
mod state;
|
mod state;
|
||||||
mod account;
|
mod account;
|
||||||
mod account_db;
|
mod account_db;
|
||||||
mod null_engine;
|
|
||||||
mod builtin;
|
mod builtin;
|
||||||
mod substate;
|
mod substate;
|
||||||
mod executive;
|
mod executive;
|
||||||
|
@ -1,3 +1,19 @@
|
|||||||
|
// 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 <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
//! Database migrations.
|
//! Database migrations.
|
||||||
|
|
||||||
pub mod state;
|
pub mod state;
|
||||||
|
@ -29,7 +29,7 @@ use error::*;
|
|||||||
use transaction::SignedTransaction;
|
use transaction::SignedTransaction;
|
||||||
use receipt::Receipt;
|
use receipt::Receipt;
|
||||||
use spec::Spec;
|
use spec::Spec;
|
||||||
use engine::Engine;
|
use engines::Engine;
|
||||||
use miner::{MinerService, MinerStatus, TransactionQueue, AccountDetails, TransactionOrigin};
|
use miner::{MinerService, MinerStatus, TransactionQueue, AccountDetails, TransactionOrigin};
|
||||||
use miner::work_notify::WorkPoster;
|
use miner::work_notify::WorkPoster;
|
||||||
use client::TransactionImportResult;
|
use client::TransactionImportResult;
|
||||||
|
@ -17,14 +17,12 @@
|
|||||||
//! Parameters for a block chain.
|
//! Parameters for a block chain.
|
||||||
|
|
||||||
use common::*;
|
use common::*;
|
||||||
use engine::*;
|
use engines::{Engine, NullEngine, BasicAuthority};
|
||||||
use pod_state::*;
|
use pod_state::*;
|
||||||
use null_engine::*;
|
|
||||||
use account_db::*;
|
use account_db::*;
|
||||||
use super::genesis::Genesis;
|
use super::genesis::Genesis;
|
||||||
use super::seal::Generic as GenericSeal;
|
use super::seal::Generic as GenericSeal;
|
||||||
use ethereum;
|
use ethereum;
|
||||||
use basic_authority::BasicAuthority;
|
|
||||||
use ethjson;
|
use ethjson;
|
||||||
|
|
||||||
/// Parameters common to all engines.
|
/// Parameters common to all engines.
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
use common::*;
|
use common::*;
|
||||||
use engine::Engine;
|
use engines::Engine;
|
||||||
use executive::{Executive, TransactOptions};
|
use executive::{Executive, TransactOptions};
|
||||||
use evm::Factory as EvmFactory;
|
use evm::Factory as EvmFactory;
|
||||||
use account_db::*;
|
use account_db::*;
|
||||||
|
@ -21,7 +21,7 @@ use block::{OpenBlock, Drain};
|
|||||||
use blockchain::{BlockChain, Config as BlockChainConfig};
|
use blockchain::{BlockChain, Config as BlockChainConfig};
|
||||||
use state::*;
|
use state::*;
|
||||||
use evm::Schedule;
|
use evm::Schedule;
|
||||||
use engine::*;
|
use engines::Engine;
|
||||||
use ethereum;
|
use ethereum;
|
||||||
use devtools::*;
|
use devtools::*;
|
||||||
use miner::Miner;
|
use miner::Miner;
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
use blockchain::BlockProvider;
|
use blockchain::BlockProvider;
|
||||||
use engine::Engine;
|
use engines::Engine;
|
||||||
use error::Error;
|
use error::Error;
|
||||||
use header::Header;
|
use header::Header;
|
||||||
use super::Verifier;
|
use super::Verifier;
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
use blockchain::BlockProvider;
|
use blockchain::BlockProvider;
|
||||||
use engine::Engine;
|
use engines::Engine;
|
||||||
use error::Error;
|
use error::Error;
|
||||||
use header::Header;
|
use header::Header;
|
||||||
use super::Verifier;
|
use super::Verifier;
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
/// 3. Final verification against the blockchain done before enactment.
|
/// 3. Final verification against the blockchain done before enactment.
|
||||||
|
|
||||||
use common::*;
|
use common::*;
|
||||||
use engine::Engine;
|
use engines::Engine;
|
||||||
use blockchain::*;
|
use blockchain::*;
|
||||||
|
|
||||||
/// Preprocessed block data gathered in `verify_block_unordered` call
|
/// Preprocessed block data gathered in `verify_block_unordered` call
|
||||||
@ -233,7 +233,7 @@ mod tests {
|
|||||||
use error::BlockError::*;
|
use error::BlockError::*;
|
||||||
use views::*;
|
use views::*;
|
||||||
use blockchain::*;
|
use blockchain::*;
|
||||||
use engine::*;
|
use engines::Engine;
|
||||||
use spec::*;
|
use spec::*;
|
||||||
use transaction::*;
|
use transaction::*;
|
||||||
use tests::helpers::*;
|
use tests::helpers::*;
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
use blockchain::BlockProvider;
|
use blockchain::BlockProvider;
|
||||||
use engine::Engine;
|
use engines::Engine;
|
||||||
use error::Error;
|
use error::Error;
|
||||||
use header::Header;
|
use header::Header;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user