Client now takes Spec instead of Engine
This commit is contained in:
parent
33d3a4d633
commit
3a2663ce93
@ -11,16 +11,15 @@ use util::network::{NetworkService};
|
|||||||
use ethcore::client::Client;
|
use ethcore::client::Client;
|
||||||
use ethcore::sync::EthSync;
|
use ethcore::sync::EthSync;
|
||||||
use ethcore::ethereum;
|
use ethcore::ethereum;
|
||||||
use ethcore::ethereum::ethash::Ethash;
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
::env_logger::init().ok();
|
::env_logger::init().ok();
|
||||||
let mut service = NetworkService::start().unwrap();
|
let mut service = NetworkService::start().unwrap();
|
||||||
//TODO: replace with proper genesis and chain params.
|
//TODO: replace with proper genesis and chain params.
|
||||||
let engine = Ethash::new_arc(ethereum::new_frontier());
|
let spec = ethereum::new_frontier();
|
||||||
let mut dir = env::temp_dir();
|
let mut dir = env::temp_dir();
|
||||||
dir.push(H32::random().hex());
|
dir.push(H32::random().hex());
|
||||||
let client = Arc::new(Client::new(engine, &dir));
|
let client = Arc::new(Client::new(spec, &dir).unwrap());
|
||||||
EthSync::register(&mut service, client);
|
EthSync::register(&mut service, client);
|
||||||
loop {
|
loop {
|
||||||
let mut cmd = String::new();
|
let mut cmd = String::new();
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
use util::*;
|
use util::*;
|
||||||
use blockchain::BlockChain;
|
use blockchain::BlockChain;
|
||||||
use views::BlockView;
|
use views::BlockView;
|
||||||
use error::ImportError;
|
use error::*;
|
||||||
use header::BlockNumber;
|
use header::BlockNumber;
|
||||||
|
use spec::Spec;
|
||||||
use engine::Engine;
|
use engine::Engine;
|
||||||
|
|
||||||
/// General block status
|
/// General block status
|
||||||
@ -95,16 +96,17 @@ pub trait BlockChainClient : Sync {
|
|||||||
/// Blockchain database client backed by a persistent database. Owns and manages a blockchain and a block queue.
|
/// Blockchain database client backed by a persistent database. Owns and manages a blockchain and a block queue.
|
||||||
pub struct Client {
|
pub struct Client {
|
||||||
chain: Arc<BlockChain>,
|
chain: Arc<BlockChain>,
|
||||||
_engine: Arc<Engine>,
|
_engine: Arc<Box<Engine>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Client {
|
impl Client {
|
||||||
pub fn new(engine: Arc<Engine>, path: &Path) -> Client {
|
pub fn new(spec: Spec, path: &Path) -> Result<Client, Error> {
|
||||||
let chain = Arc::new(BlockChain::new(&engine.spec().genesis_block(), path));
|
let chain = Arc::new(BlockChain::new(&spec.genesis_block(), path));
|
||||||
Client {
|
let engine = Arc::new(try!(spec.to_engine()));
|
||||||
|
Ok(Client {
|
||||||
chain: chain.clone(),
|
chain: chain.clone(),
|
||||||
_engine: engine.clone(),
|
_engine: engine,
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,10 +13,6 @@ impl Ethash {
|
|||||||
pub fn new_boxed(spec: Spec) -> Box<Engine> {
|
pub fn new_boxed(spec: Spec) -> Box<Engine> {
|
||||||
Box::new(Ethash{spec: spec})
|
Box::new(Ethash{spec: spec})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_arc(spec: Spec) -> Arc<Engine> {
|
|
||||||
Arc::new(Ethash{spec: spec})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Engine for Ethash {
|
impl Engine for Ethash {
|
||||||
|
@ -13,13 +13,11 @@
|
|||||||
/// use ethcore::client::Client;
|
/// use ethcore::client::Client;
|
||||||
/// use ethcore::sync::EthSync;
|
/// use ethcore::sync::EthSync;
|
||||||
/// use ethcore::ethereum;
|
/// use ethcore::ethereum;
|
||||||
/// use ethcore::ethereum::ethash::Ethash;
|
|
||||||
///
|
///
|
||||||
/// fn main() {
|
/// fn main() {
|
||||||
/// let mut service = NetworkService::start().unwrap();
|
/// let mut service = NetworkService::start().unwrap();
|
||||||
/// let engine = Ethash::new_arc(ethereum::new_frontier());
|
|
||||||
/// let dir = env::temp_dir();
|
/// let dir = env::temp_dir();
|
||||||
/// let client = Arc::new(Client::new(engine, &dir));
|
/// let client = Arc::new(Client::new(ethereum::new_frontier(), &dir).unwrap());
|
||||||
/// EthSync::register(&mut service, client);
|
/// EthSync::register(&mut service, client);
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
Loading…
Reference in New Issue
Block a user