Skip to content
This repository was archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Collect consensus/null engines into a single module (#1754)
Browse files Browse the repository at this point in the history
* collect consesnsus engine code into module

* move Engine to mod

* fix json test
  • Loading branch information
keorn authored and gavofyork committed Jul 28, 2016
1 parent b62a5c8 commit 11cb544
Show file tree
Hide file tree
Showing 20 changed files with 49 additions and 31 deletions.
2 changes: 1 addition & 1 deletion ethcore/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
//! Blockchain block.
use common::*;
use engine::*;
use engines::Engine;
use state::*;
use verification::PreverifiedBlock;
use trace::FlatTrace;
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/block_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/client/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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() {
Expand Down
8 changes: 7 additions & 1 deletion ethcore/src/engine.rs → ethcore/src/engines/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/ethereum/ethash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/executive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down
4 changes: 2 additions & 2 deletions ethcore/src/externalities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down Expand Up @@ -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::*;
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/json_tests/executive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down
4 changes: 1 addition & 3 deletions ethcore/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -127,7 +126,6 @@ mod pod_account;
mod state;
mod account;
mod account_db;
mod null_engine;
mod builtin;
mod substate;
mod executive;
Expand Down
16 changes: 16 additions & 0 deletions ethcore/src/migrations/mod.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/miner/miner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 1 addition & 3 deletions ethcore/src/spec/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/tests/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/verification/canon_verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/verification/noop_verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions ethcore/src/verification/verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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::*;
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/verification/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 11cb544

Please sign in to comment.