From c951dee7668e4d6ef5164230bdc1d41b77e4254e Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Thu, 10 Mar 2016 17:09:34 +0100 Subject: [PATCH 1/2] --archive is default. --pruning is option. --- parity/main.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/parity/main.rs b/parity/main.rs index 68d45bc04..69650270a 100644 --- a/parity/main.rs +++ b/parity/main.rs @@ -79,7 +79,7 @@ Protocol Options: or olympic, frontier, homestead, mainnet, morden, or testnet [default: homestead]. --testnet Equivalent to --chain testnet (geth-compatible). --networkid INDEX Override the network identifier from the chain we are on. - --archive Client should not prune the state/storage trie. + --pruning Client should prune the state/storage trie. -d --datadir PATH Specify the database & configuration directory path [default: $HOME/.parity] --keys-path PATH Specify the path for JSON key files to be found [default: $HOME/.web3/keys] --identity NAME Specify your node's name. @@ -140,7 +140,7 @@ struct Args { flag_identity: String, flag_cache: Option, flag_keys_path: String, - flag_archive: bool, + flag_pruning: bool, flag_no_bootstrap: bool, flag_listen_address: String, flag_public_address: Option, @@ -402,7 +402,7 @@ impl Configuration { client_config.blockchain.max_cache_size = self.args.flag_cache_max_size; } } - client_config.prefer_journal = !self.args.flag_archive; + client_config.prefer_journal = self.args.flag_pruning; client_config.name = self.args.flag_identity.clone(); client_config.queue.max_mem_use = self.args.flag_queue_max_size; let mut service = ClientService::start(client_config, spec, net_settings, &Path::new(&self.path())).unwrap(); From 25a63611f856ab0896b114b6388461c174bf9905 Mon Sep 17 00:00:00 2001 From: Nikolay Volf Date: Thu, 10 Mar 2016 20:32:17 +0400 Subject: [PATCH 2/2] extend sync status interface to sync provider --- parity/main.rs | 2 +- rpc/src/v1/impls/eth.rs | 8 ++++---- rpc/src/v1/impls/net.rs | 8 ++++---- sync/src/lib.rs | 20 +++++++++++--------- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/parity/main.rs b/parity/main.rs index 8814da44b..d2b9b3567 100644 --- a/parity/main.rs +++ b/parity/main.rs @@ -49,7 +49,7 @@ use ethcore::spec::*; use ethcore::client::*; use ethcore::service::{ClientService, NetSyncMessage}; use ethcore::ethereum; -use ethsync::{EthSync, SyncConfig, SyncStatusProvider}; +use ethsync::{EthSync, SyncConfig, SyncProvider}; use docopt::Docopt; use daemonize::Daemonize; use number_prefix::{binary_prefix, Standalone, Prefixed}; diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index 91bd0cce3..a067b48fb 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -17,7 +17,7 @@ //! Eth rpc implementation. use std::collections::HashMap; use std::sync::{Arc, Weak, Mutex, RwLock}; -use ethsync::{SyncStatusProvider, SyncState}; +use ethsync::{SyncProvider, SyncState}; use jsonrpc_core::*; use util::numbers::*; use util::sha3::*; @@ -32,13 +32,13 @@ use v1::types::{Block, BlockTransactions, BlockNumber, Bytes, SyncStatus, SyncIn use v1::helpers::{PollFilter, PollManager}; /// Eth rpc implementation. -pub struct EthClient where C: BlockChainClient, S: SyncStatusProvider { +pub struct EthClient where C: BlockChainClient, S: SyncProvider { client: Weak, sync: Weak, hashrates: RwLock>, } -impl EthClient where C: BlockChainClient, S: SyncStatusProvider { +impl EthClient where C: BlockChainClient, S: SyncProvider { /// Creates new EthClient. pub fn new(client: &Arc, sync: &Arc) -> Self { EthClient { @@ -94,7 +94,7 @@ impl EthClient where C: BlockChainClient, S: SyncStatusProvider { } } -impl Eth for EthClient where C: BlockChainClient + 'static, S: SyncStatusProvider + 'static { +impl Eth for EthClient where C: BlockChainClient + 'static, S: SyncProvider + 'static { fn protocol_version(&self, params: Params) -> Result { match params { Params::None => to_value(&U256::from(take_weak!(self.sync).status().protocol_version)), diff --git a/rpc/src/v1/impls/net.rs b/rpc/src/v1/impls/net.rs index a686ed66f..5e67bf252 100644 --- a/rpc/src/v1/impls/net.rs +++ b/rpc/src/v1/impls/net.rs @@ -17,15 +17,15 @@ //! Net rpc implementation. use std::sync::{Arc, Weak}; use jsonrpc_core::*; -use ethsync::SyncStatusProvider; +use ethsync::SyncProvider; use v1::traits::Net; /// Net rpc implementation. -pub struct NetClient where S: SyncStatusProvider { +pub struct NetClient where S: SyncProvider { sync: Weak } -impl NetClient where S: SyncStatusProvider { +impl NetClient where S: SyncProvider { /// Creates new NetClient. pub fn new(sync: &Arc) -> Self { NetClient { @@ -34,7 +34,7 @@ impl NetClient where S: SyncStatusProvider { } } -impl Net for NetClient where S: SyncStatusProvider + 'static { +impl Net for NetClient where S: SyncProvider + 'static { fn version(&self, _: Params) -> Result { Ok(Value::U64(take_weak!(self.sync).status().protocol_version as u64)) } diff --git a/sync/src/lib.rs b/sync/src/lib.rs index 5a0ba79c5..3b79e5614 100644 --- a/sync/src/lib.rs +++ b/sync/src/lib.rs @@ -95,9 +95,11 @@ impl Default for SyncConfig { } /// Current sync status -pub trait SyncStatusProvider: Send + Sync { +pub trait SyncProvider: Send + Sync { /// Get sync status fn status(&self) -> SyncStatus; + /// Insert transaction in the sync transaction queue + fn insert_transaction(&self, transaction: ethcore::transaction::SignedTransaction); } /// Ethereum network protocol handler @@ -130,9 +132,16 @@ impl EthSync { pub fn restart(&mut self, io: &mut NetworkContext) { self.sync.write().unwrap().restart(&mut NetSyncIo::new(io, self.chain.deref())); } +} + +impl SyncProvider for EthSync { + /// Get sync status + fn status(&self) -> SyncStatus { + self.sync.read().unwrap().status() + } /// Insert transaction in transaction queue - pub fn insert_transaction(&self, transaction: ethcore::transaction::SignedTransaction) { + fn insert_transaction(&self, transaction: ethcore::transaction::SignedTransaction) { use util::numbers::*; let nonce_fn = |a: &Address| self.chain.state().nonce(a) + U256::one(); @@ -141,13 +150,6 @@ impl EthSync { } } -impl SyncStatusProvider for EthSync { - /// Get sync status - fn status(&self) -> SyncStatus { - self.sync.read().unwrap().status() - } -} - impl NetworkProtocolHandler for EthSync { fn initialize(&self, io: &NetworkContext) { io.register_timer(0, 1000).expect("Error registering sync timer");