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:
keorn 2016-07-28 20:32:20 +02:00 committed by Gav Wood
parent b62a5c8f7d
commit 11cb544c24
20 changed files with 49 additions and 31 deletions

View File

@ -17,7 +17,7 @@
//! Blockchain block.
use common::*;
use engine::*;
use engines::Engine;
use state::*;
use verification::PreverifiedBlock;
use trace::FlatTrace;

View File

@ -22,7 +22,7 @@ use std::sync::{Condvar as SCondvar, Mutex as SMutex};
use util::*;
use verification::*;
use error::*;
use engine::Engine;
use engines::Engine;
use views::*;
use header::*;
use service::*;

View File

@ -40,7 +40,7 @@ use header::BlockNumber;
use state::State;
use spec::Spec;
use basic_types::Seal;
use engine::Engine;
use engines::Engine;
use views::HeaderView;
use service::ClientIoMessage;
use env_info::LastHashes;

View File

@ -19,8 +19,8 @@
use common::*;
use account_provider::AccountProvider;
use block::*;
use spec::{CommonParams, Spec};
use engine::*;
use spec::CommonParams;
use engines::Engine;
use evm::Schedule;
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)]
mod tests {
use super::*;
use common::*;
use block::*;
use tests::helpers::*;
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]
fn has_valid_metadata() {

View File

@ -14,7 +14,13 @@
// You should have received a copy of the GNU General Public License
// 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 account_provider::AccountProvider;

View File

@ -17,12 +17,12 @@
use std::collections::BTreeMap;
use util::hash::Address;
use builtin::Builtin;
use engine::Engine;
use engines::Engine;
use spec::CommonParams;
use evm::Schedule;
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 {
params: CommonParams,
builtins: BTreeMap<Address, Builtin>,

View File

@ -18,7 +18,7 @@ use ethash::{quick_get_difficulty, EthashManager, H256 as EH256};
use common::*;
use block::*;
use spec::CommonParams;
use engine::*;
use engines::Engine;
use evm::Schedule;
use ethjson;

View File

@ -17,7 +17,7 @@
//! Transaction Execution environment.
use common::*;
use state::*;
use engine::*;
use engines::Engine;
use types::executed::CallType;
use evm::{self, Ext, Factory, Finalize};
use externalities::*;

View File

@ -17,7 +17,7 @@
//! Transaction Execution environment.
use common::*;
use state::*;
use engine::*;
use engines::Engine;
use executive::*;
use evm::{self, Schedule, Ext, ContractCreateResult, MessageCallResult, Factory};
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 {
use common::*;
use state::*;
use engine::*;
use engines::Engine;
use evm::{Ext};
use substate::*;
use tests::helpers::*;

View File

@ -17,7 +17,7 @@
use super::test_common::*;
use state::*;
use executive::*;
use engine::*;
use engines::Engine;
use evm;
use evm::{Schedule, Ext, Factory, Finalize, VMType, ContractCreateResult, MessageCallResult};
use externalities::*;

View File

@ -99,7 +99,7 @@ extern crate ethcore_devtools as devtools;
#[cfg(feature = "jit" )] extern crate evmjit;
pub mod account_provider;
pub mod basic_authority;
pub mod engines;
pub mod block;
pub mod block_queue;
pub mod client;
@ -111,7 +111,6 @@ pub mod trace;
pub mod spec;
pub mod views;
pub mod pod_state;
pub mod engine;
pub mod migrations;
pub mod miner;
pub mod snapshot;
@ -127,7 +126,6 @@ mod pod_account;
mod state;
mod account;
mod account_db;
mod null_engine;
mod builtin;
mod substate;
mod executive;

View File

@ -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.
pub mod state;

View File

@ -29,7 +29,7 @@ use error::*;
use transaction::SignedTransaction;
use receipt::Receipt;
use spec::Spec;
use engine::Engine;
use engines::Engine;
use miner::{MinerService, MinerStatus, TransactionQueue, AccountDetails, TransactionOrigin};
use miner::work_notify::WorkPoster;
use client::TransactionImportResult;

View File

@ -17,14 +17,12 @@
//! Parameters for a block chain.
use common::*;
use engine::*;
use engines::{Engine, NullEngine, BasicAuthority};
use pod_state::*;
use null_engine::*;
use account_db::*;
use super::genesis::Genesis;
use super::seal::Generic as GenericSeal;
use ethereum;
use basic_authority::BasicAuthority;
use ethjson;
/// Parameters common to all engines.

View File

@ -15,7 +15,7 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
use common::*;
use engine::Engine;
use engines::Engine;
use executive::{Executive, TransactOptions};
use evm::Factory as EvmFactory;
use account_db::*;

View File

@ -21,7 +21,7 @@ use block::{OpenBlock, Drain};
use blockchain::{BlockChain, Config as BlockChainConfig};
use state::*;
use evm::Schedule;
use engine::*;
use engines::Engine;
use ethereum;
use devtools::*;
use miner::Miner;

View File

@ -15,7 +15,7 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
use blockchain::BlockProvider;
use engine::Engine;
use engines::Engine;
use error::Error;
use header::Header;
use super::Verifier;

View File

@ -15,7 +15,7 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
use blockchain::BlockProvider;
use engine::Engine;
use engines::Engine;
use error::Error;
use header::Header;
use super::Verifier;

View File

@ -22,7 +22,7 @@
/// 3. Final verification against the blockchain done before enactment.
use common::*;
use engine::Engine;
use engines::Engine;
use blockchain::*;
/// Preprocessed block data gathered in `verify_block_unordered` call
@ -233,7 +233,7 @@ mod tests {
use error::BlockError::*;
use views::*;
use blockchain::*;
use engine::*;
use engines::Engine;
use spec::*;
use transaction::*;
use tests::helpers::*;

View File

@ -15,7 +15,7 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
use blockchain::BlockProvider;
use engine::Engine;
use engines::Engine;
use error::Error;
use header::Header;