ethcore-service (#8089)
* ethcore test::helpers cleanup * ethcore-service
This commit is contained in:
parent
e0f71b0c17
commit
de72643898
15
Cargo.lock
generated
15
Cargo.lock
generated
@ -715,6 +715,20 @@ dependencies = [
|
||||
"url 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ethcore-service"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"ansi_term 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ethcore 1.11.0",
|
||||
"ethcore-io 1.11.0",
|
||||
"kvdb 0.1.0",
|
||||
"kvdb-rocksdb 0.1.0",
|
||||
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"stop-guard 0.1.0",
|
||||
"tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ethcore-stratum"
|
||||
version = "1.11.0"
|
||||
@ -1948,6 +1962,7 @@ dependencies = [
|
||||
"ethcore-miner 1.11.0",
|
||||
"ethcore-network 1.11.0",
|
||||
"ethcore-secretstore 1.0.0",
|
||||
"ethcore-service 0.1.0",
|
||||
"ethcore-stratum 1.11.0",
|
||||
"ethcore-transaction 0.1.0",
|
||||
"ethereum-types 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -43,6 +43,7 @@ ethcore-logger = { path = "logger" }
|
||||
ethcore-migrations = { path = "ethcore/migrations" }
|
||||
ethcore-miner = { path = "miner" }
|
||||
ethcore-network = { path = "util/network" }
|
||||
ethcore-service = { path = "ethcore/service" }
|
||||
ethcore-stratum = { path = "stratum" }
|
||||
ethcore-transaction = { path = "ethcore/transaction" }
|
||||
ethereum-types = "0.2"
|
||||
@ -132,6 +133,5 @@ members = [
|
||||
"evmbin",
|
||||
"miner",
|
||||
"transaction-pool",
|
||||
"whisper",
|
||||
"util/rlp_compress"
|
||||
"whisper"
|
||||
]
|
||||
|
@ -19,7 +19,7 @@
|
||||
use std::sync::{Weak, Arc};
|
||||
|
||||
use ethcore::block_status::BlockStatus;
|
||||
use ethcore::client::{ClientReport, EnvInfo};
|
||||
use ethcore::client::{ClientReport, EnvInfo, ClientIoMessage};
|
||||
use ethcore::engines::{epoch, EthEngine, EpochChange, EpochTransition, Proof};
|
||||
use ethcore::machine::EthereumMachine;
|
||||
use ethcore::error::BlockImportError;
|
||||
@ -28,7 +28,6 @@ use ethcore::header::{BlockNumber, Header};
|
||||
use ethcore::verification::queue::{self, HeaderQueue};
|
||||
use ethcore::blockchain_info::BlockChainInfo;
|
||||
use ethcore::spec::Spec;
|
||||
use ethcore::service::ClientIoMessage;
|
||||
use ethcore::encoded;
|
||||
use io::IoChannel;
|
||||
use parking_lot::{Mutex, RwLock};
|
||||
|
@ -20,8 +20,8 @@
|
||||
use std::fmt;
|
||||
use std::sync::Arc;
|
||||
|
||||
use ethcore::client::ClientIoMessage;
|
||||
use ethcore::db;
|
||||
use ethcore::service::ClientIoMessage;
|
||||
use ethcore::spec::Spec;
|
||||
use io::{IoContext, IoError, IoHandler, IoService};
|
||||
use kvdb::{self, KeyValueDB};
|
||||
|
16
ethcore/service/Cargo.toml
Normal file
16
ethcore/service/Cargo.toml
Normal file
@ -0,0 +1,16 @@
|
||||
[package]
|
||||
name = "ethcore-service"
|
||||
version = "0.1.0"
|
||||
authors = ["Parity Technologies <admin@parity.io>"]
|
||||
|
||||
[dependencies]
|
||||
ansi_term = "0.10"
|
||||
ethcore = { path = ".." }
|
||||
ethcore-io = { path = "../../util/io" }
|
||||
kvdb = { path = "../../util/kvdb" }
|
||||
kvdb-rocksdb = { path = "../../util/kvdb-rocksdb" }
|
||||
log = "0.3"
|
||||
stop-guard = { path = "../../util/stop-guard" }
|
||||
|
||||
[dev-dependencies]
|
||||
tempdir = "0.3"
|
32
ethcore/service/src/lib.rs
Normal file
32
ethcore/service/src/lib.rs
Normal file
@ -0,0 +1,32 @@
|
||||
// Copyright 2015-2018 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/>.
|
||||
|
||||
extern crate ansi_term;
|
||||
extern crate ethcore;
|
||||
extern crate ethcore_io as io;
|
||||
extern crate kvdb;
|
||||
extern crate kvdb_rocksdb;
|
||||
extern crate stop_guard;
|
||||
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
|
||||
#[cfg(test)]
|
||||
extern crate tempdir;
|
||||
|
||||
mod service;
|
||||
|
||||
pub use service::ClientService;
|
@ -18,41 +18,20 @@
|
||||
|
||||
use std::sync::Arc;
|
||||
use std::path::Path;
|
||||
use ethereum_types::H256;
|
||||
|
||||
use ansi_term::Colour;
|
||||
use io::{IoContext, TimerToken, IoHandler, IoService, IoError};
|
||||
use kvdb::KeyValueDB;
|
||||
use kvdb_rocksdb::{Database, DatabaseConfig};
|
||||
use bytes::Bytes;
|
||||
use io::*;
|
||||
use spec::Spec;
|
||||
use error::*;
|
||||
use client::{Client, ClientConfig, ChainNotify};
|
||||
use miner::Miner;
|
||||
|
||||
use snapshot::{ManifestData, RestorationStatus};
|
||||
use snapshot::service::{Service as SnapshotService, ServiceParams as SnapServiceParams};
|
||||
use ansi_term::Colour;
|
||||
use stop_guard::StopGuard;
|
||||
|
||||
/// Message type for external and internal events
|
||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||
pub enum ClientIoMessage {
|
||||
/// Best Block Hash in chain has been changed
|
||||
NewChainHead,
|
||||
/// A block is ready
|
||||
BlockVerified,
|
||||
/// New transaction RLPs are ready to be imported
|
||||
NewTransactions(Vec<Bytes>, usize),
|
||||
/// Begin snapshot restoration
|
||||
BeginRestoration(ManifestData),
|
||||
/// Feed a state chunk to the snapshot service
|
||||
FeedStateChunk(H256, Bytes),
|
||||
/// Feed a block chunk to the snapshot service
|
||||
FeedBlockChunk(H256, Bytes),
|
||||
/// Take a snapshot for the block with given number.
|
||||
TakeSnapshot(u64),
|
||||
/// New consensus message received.
|
||||
NewMessage(Bytes)
|
||||
}
|
||||
use ethcore::client::{self, Client, ClientConfig, ChainNotify, ClientIoMessage};
|
||||
use ethcore::db;
|
||||
use ethcore::error::Error;
|
||||
use ethcore::miner::Miner;
|
||||
use ethcore::snapshot::service::{Service as SnapshotService, ServiceParams as SnapServiceParams};
|
||||
use ethcore::snapshot::{RestorationStatus};
|
||||
use ethcore::spec::Spec;
|
||||
|
||||
/// Client service setup. Creates and registers client and network services with the IO subsystem.
|
||||
pub struct ClientService {
|
||||
@ -78,7 +57,7 @@ impl ClientService {
|
||||
|
||||
info!("Configured for {} using {} engine", Colour::White.bold().paint(spec.name.clone()), Colour::Yellow.bold().paint(spec.engine.name()));
|
||||
|
||||
let mut db_config = DatabaseConfig::with_columns(::db::NUM_COLUMNS);
|
||||
let mut db_config = DatabaseConfig::with_columns(db::NUM_COLUMNS);
|
||||
|
||||
db_config.memory_budget = config.db_cache_size;
|
||||
db_config.compaction = config.db_compaction.compaction_profile(client_path);
|
||||
@ -87,7 +66,7 @@ impl ClientService {
|
||||
let db = Arc::new(Database::open(
|
||||
&db_config,
|
||||
&client_path.to_str().expect("DB path could not be converted to string.")
|
||||
).map_err(::client::Error::Database)?);
|
||||
).map_err(client::Error::Database)?);
|
||||
|
||||
|
||||
let pruning = config.pruning;
|
||||
@ -173,7 +152,7 @@ impl IoHandler<ClientIoMessage> for ClientIoHandler {
|
||||
fn timeout(&self, _io: &IoContext<ClientIoMessage>, timer: TimerToken) {
|
||||
match timer {
|
||||
CLIENT_TICK_TIMER => {
|
||||
use snapshot::SnapshotService;
|
||||
use ethcore::snapshot::SnapshotService;
|
||||
let snapshot_restoration = if let RestorationStatus::Ongoing{..} = self.snapshot.status() { true } else { false };
|
||||
self.client.tick(snapshot_restoration)
|
||||
},
|
||||
@ -221,14 +200,16 @@ impl IoHandler<ClientIoMessage> for ClientIoHandler {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::{time, thread};
|
||||
use spec::Spec;
|
||||
use super::*;
|
||||
use client::ClientConfig;
|
||||
use std::sync::Arc;
|
||||
use miner::Miner;
|
||||
use std::{time, thread};
|
||||
|
||||
use tempdir::TempDir;
|
||||
|
||||
use ethcore::client::ClientConfig;
|
||||
use ethcore::miner::Miner;
|
||||
use ethcore::spec::Spec;
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn it_can_be_started() {
|
||||
let tempdir = TempDir::new("").unwrap();
|
@ -37,8 +37,11 @@ use blockchain::{BlockChain, BlockProvider, TreeRoute, ImportRoute, Transaction
|
||||
use client::ancient_import::AncientVerifier;
|
||||
use client::Error as ClientError;
|
||||
use client::{
|
||||
Nonce, Balance, ChainInfo, BlockInfo, CallContract, TransactionInfo, RegistryInfo, ReopenBlock, PrepareOpenBlock, ScheduleInfo, ImportSealedBlock, BroadcastProposalBlock, ImportBlock,
|
||||
StateOrBlock, StateInfo, StateClient, Call, AccountData, BlockChain as BlockChainTrait, BlockProducer, SealedBlockImporter
|
||||
Nonce, Balance, ChainInfo, BlockInfo, CallContract, TransactionInfo,
|
||||
RegistryInfo, ReopenBlock, PrepareOpenBlock, ScheduleInfo, ImportSealedBlock,
|
||||
BroadcastProposalBlock, ImportBlock, StateOrBlock, StateInfo, StateClient, Call,
|
||||
AccountData, BlockChain as BlockChainTrait, BlockProducer, SealedBlockImporter,
|
||||
ClientIoMessage
|
||||
};
|
||||
use client::{
|
||||
BlockId, TransactionId, UncleId, TraceId, ClientConfig, BlockChainClient,
|
||||
@ -60,7 +63,6 @@ use parking_lot::{Mutex, RwLock};
|
||||
use rand::OsRng;
|
||||
use receipt::{Receipt, LocalizedReceipt};
|
||||
use rlp::UntrustedRlp;
|
||||
use service::ClientIoMessage;
|
||||
use snapshot::{self, io as snapshot_io};
|
||||
use spec::Spec;
|
||||
use state_db::StateDB;
|
||||
|
41
ethcore/src/client/io_message.rs
Normal file
41
ethcore/src/client/io_message.rs
Normal file
@ -0,0 +1,41 @@
|
||||
// Copyright 2015-2018 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/>.
|
||||
|
||||
use ethereum_types::H256;
|
||||
use bytes::Bytes;
|
||||
use snapshot::ManifestData;
|
||||
|
||||
/// Message type for external and internal events
|
||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||
pub enum ClientIoMessage {
|
||||
/// Best Block Hash in chain has been changed
|
||||
NewChainHead,
|
||||
/// A block is ready
|
||||
BlockVerified,
|
||||
/// New transaction RLPs are ready to be imported
|
||||
NewTransactions(Vec<Bytes>, usize),
|
||||
/// Begin snapshot restoration
|
||||
BeginRestoration(ManifestData),
|
||||
/// Feed a state chunk to the snapshot service
|
||||
FeedStateChunk(H256, Bytes),
|
||||
/// Feed a block chunk to the snapshot service
|
||||
FeedBlockChunk(H256, Bytes),
|
||||
/// Take a snapshot for the block with given number.
|
||||
TakeSnapshot(u64),
|
||||
/// New consensus message received.
|
||||
NewMessage(Bytes)
|
||||
}
|
||||
|
@ -17,17 +17,19 @@
|
||||
//! Blockchain database client.
|
||||
|
||||
mod ancient_import;
|
||||
mod client;
|
||||
mod config;
|
||||
mod error;
|
||||
mod evm_test_client;
|
||||
mod io_message;
|
||||
mod test_client;
|
||||
mod trace;
|
||||
mod client;
|
||||
|
||||
pub use self::client::*;
|
||||
pub use self::config::{Mode, ClientConfig, DatabaseCompactionProfile, BlockChainConfig, VMType};
|
||||
pub use self::error::Error;
|
||||
pub use self::evm_test_client::{EvmTestClient, EvmTestError, TransactResult};
|
||||
pub use self::io_message::ClientIoMessage;
|
||||
pub use self::test_client::{TestBlockChainClient, EachBlockWith};
|
||||
pub use self::chain_notify::ChainNotify;
|
||||
pub use self::traits::{
|
||||
|
@ -148,7 +148,6 @@ pub mod header;
|
||||
pub mod machine;
|
||||
pub mod miner;
|
||||
pub mod pod_state;
|
||||
pub mod service;
|
||||
pub mod snapshot;
|
||||
pub mod spec;
|
||||
pub mod state;
|
||||
|
@ -27,11 +27,10 @@ use super::{ManifestData, StateRebuilder, Rebuilder, RestorationStatus, Snapshot
|
||||
use super::io::{SnapshotReader, LooseReader, SnapshotWriter, LooseWriter};
|
||||
|
||||
use blockchain::BlockChain;
|
||||
use client::{Client, ChainInfo};
|
||||
use client::{Client, ChainInfo, ClientIoMessage};
|
||||
use engines::EthEngine;
|
||||
use error::Error;
|
||||
use ids::BlockId;
|
||||
use service::ClientIoMessage;
|
||||
|
||||
use io::IoChannel;
|
||||
|
||||
@ -631,7 +630,7 @@ impl Drop for Service {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::sync::Arc;
|
||||
use service::ClientIoMessage;
|
||||
use client::ClientIoMessage;
|
||||
use io::{IoService};
|
||||
use spec::Spec;
|
||||
use journaldb::Algorithm;
|
||||
|
@ -17,9 +17,8 @@
|
||||
//! Watcher for snapshot-related chain events.
|
||||
|
||||
use parking_lot::Mutex;
|
||||
use client::{BlockInfo, Client, ChainNotify};
|
||||
use client::{BlockInfo, Client, ChainNotify, ClientIoMessage};
|
||||
use ids::BlockId;
|
||||
use service::ClientIoMessage;
|
||||
|
||||
use io::IoChannel;
|
||||
use ethereum_types::H256;
|
||||
|
@ -28,7 +28,7 @@ use parking_lot::{Condvar, Mutex, RwLock};
|
||||
use io::*;
|
||||
use error::*;
|
||||
use engines::EthEngine;
|
||||
use service::*;
|
||||
use client::ClientIoMessage;
|
||||
|
||||
use self::kind::{BlockLike, Kind};
|
||||
|
||||
|
@ -23,7 +23,7 @@ use transaction::{
|
||||
SignedTransaction, PendingTransaction, UnverifiedTransaction,
|
||||
Condition as TransactionCondition
|
||||
};
|
||||
use ethcore::service::ClientIoMessage;
|
||||
use ethcore::client::ClientIoMessage;
|
||||
use io::IoHandler;
|
||||
use rlp::UntrustedRlp;
|
||||
use kvdb::KeyValueDB;
|
||||
|
@ -25,12 +25,12 @@ use hash::{keccak, KECCAK_NULL_RLP};
|
||||
use ethereum_types::{U256, H256, Address};
|
||||
use bytes::ToPretty;
|
||||
use rlp::PayloadInfo;
|
||||
use ethcore::service::ClientService;
|
||||
use ethcore::client::{Mode, DatabaseCompactionProfile, VMType, BlockImportError, Nonce, Balance, BlockChainClient, BlockId, BlockInfo, ImportBlock};
|
||||
use ethcore::db::NUM_COLUMNS;
|
||||
use ethcore::error::ImportError;
|
||||
use ethcore::miner::Miner;
|
||||
use ethcore::verification::queue::VerifierSettings;
|
||||
use ethcore_service::ClientService;
|
||||
use cache::CacheConfig;
|
||||
use informant::{Informant, FullNodeInformantData, MillisecondDuration};
|
||||
use kvdb_rocksdb::{Database, DatabaseConfig};
|
||||
|
@ -22,9 +22,11 @@ use std::sync::{Arc};
|
||||
use std::sync::atomic::{AtomicUsize, AtomicBool, Ordering as AtomicOrdering};
|
||||
use std::time::{Instant, Duration};
|
||||
|
||||
use ethcore::client::{BlockId, BlockChainClient, ChainInfo, BlockInfo, BlockChainInfo, BlockQueueInfo, ChainNotify, ClientReport, Client};
|
||||
use ethcore::client::{
|
||||
BlockId, BlockChainClient, ChainInfo, BlockInfo, BlockChainInfo,
|
||||
BlockQueueInfo, ChainNotify, ClientReport, Client, ClientIoMessage
|
||||
};
|
||||
use ethcore::header::BlockNumber;
|
||||
use ethcore::service::ClientIoMessage;
|
||||
use ethcore::snapshot::{RestorationStatus, SnapshotService as SS};
|
||||
use ethcore::snapshot::service::Service as SnapshotService;
|
||||
use ethsync::{LightSyncProvider, LightSync, SyncProvider, ManageNetwork};
|
||||
|
@ -19,7 +19,7 @@
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
|
||||
use ethcore::service::ClientIoMessage;
|
||||
use ethcore::client::ClientIoMessage;
|
||||
use ethsync::LightSync;
|
||||
use io::{IoContext, IoHandler, TimerToken};
|
||||
|
||||
|
@ -54,6 +54,7 @@ extern crate ethcore_logger;
|
||||
extern crate ethcore_migrations as migrations;
|
||||
extern crate ethcore_miner as miner;
|
||||
extern crate ethcore_network as network;
|
||||
extern crate ethcore_service;
|
||||
extern crate ethcore_transaction as transaction;
|
||||
extern crate ethereum_types;
|
||||
extern crate migration as migr;
|
||||
|
@ -28,11 +28,11 @@ use ethcore::db::NUM_COLUMNS;
|
||||
use ethcore::ethstore::ethkey;
|
||||
use ethcore::miner::{Miner, MinerService, MinerOptions};
|
||||
use ethcore::miner::{StratumOptions, Stratum};
|
||||
use ethcore::service::ClientService;
|
||||
use ethcore::snapshot;
|
||||
use ethcore::spec::{SpecParams, OptimizeFor};
|
||||
use ethcore::verification::queue::VerifierSettings;
|
||||
use ethcore_logger::{Config as LogConfig, RotatingLogger};
|
||||
use ethcore_service::ClientService;
|
||||
use ethsync::{self, SyncConfig};
|
||||
use fdlimit::raise_fd_limit;
|
||||
use hash_fetch::fetch::{Fetch, Client as FetchClient};
|
||||
|
@ -24,10 +24,10 @@ use hash::keccak;
|
||||
use ethcore::snapshot::{Progress, RestorationStatus, SnapshotService as SS};
|
||||
use ethcore::snapshot::io::{SnapshotReader, PackedReader, PackedWriter};
|
||||
use ethcore::snapshot::service::Service as SnapshotService;
|
||||
use ethcore::service::ClientService;
|
||||
use ethcore::client::{Mode, DatabaseCompactionProfile, VMType};
|
||||
use ethcore::miner::Miner;
|
||||
use ethcore::ids::BlockId;
|
||||
use ethcore_service::ClientService;
|
||||
|
||||
use cache::CacheConfig;
|
||||
use params::{SpecType, Pruning, Switch, tracing_switch_to_bool, fatdb_switch_to_bool};
|
||||
|
@ -18,8 +18,7 @@ use std::sync::Arc;
|
||||
use hash::keccak;
|
||||
use ethereum_types::{U256, Address};
|
||||
use io::{IoHandler, IoContext, IoChannel};
|
||||
use ethcore::client::{Client, ChainInfo};
|
||||
use ethcore::service::ClientIoMessage;
|
||||
use ethcore::client::{Client, ChainInfo, ClientIoMessage};
|
||||
use ethcore::spec::Spec;
|
||||
use ethcore::miner::MinerService;
|
||||
use ethcore::account_provider::AccountProvider;
|
||||
|
Loading…
Reference in New Issue
Block a user