Naming consistency and make Updater improvements.

- ID -> Id (consistency with rust libs)
This commit is contained in:
Gav Wood
2016-11-22 10:24:22 +01:00
parent 10e64847a4
commit 45dead9d49
48 changed files with 644 additions and 476 deletions

View File

@@ -25,7 +25,7 @@ use io::{PanicHandler, ForwardPanic};
use util::{ToPretty, Uint};
use rlp::PayloadInfo;
use ethcore::service::ClientService;
use ethcore::client::{Mode, DatabaseCompactionProfile, VMType, BlockImportError, BlockChainClient, BlockID};
use ethcore::client::{Mode, DatabaseCompactionProfile, VMType, BlockImportError, BlockChainClient, BlockId};
use ethcore::error::ImportError;
use ethcore::miner::Miner;
use cache::CacheConfig;
@@ -98,8 +98,8 @@ pub struct ExportBlockchain {
pub wal: bool,
pub fat_db: Switch,
pub tracing: Switch,
pub from_block: BlockID,
pub to_block: BlockID,
pub from_block: BlockId,
pub to_block: BlockId,
pub check_seal: bool,
}
@@ -329,7 +329,7 @@ fn execute_export(cmd: ExportBlockchain) -> Result<String, String> {
let to = try!(client.block_number(cmd.to_block).ok_or("To block could not be found"));
for i in from..(to + 1) {
let b = try!(client.block(BlockID::Number(i)).ok_or("Error exporting incomplete chain"));
let b = try!(client.block(BlockId::Number(i)).ok_or("Error exporting incomplete chain"));
match format {
DataFormat::Binary => { out.write(&b).expect("Couldn't write to stream."); }
DataFormat::Hex => { out.write_fmt(format_args!("{}", b.pretty())).expect("Couldn't write to stream."); }

View File

@@ -24,6 +24,14 @@ Operating Options:
wakes regularly to resync.
dark - Parity syncs only when the RPC is active.
offline - Parity doesn't sync. (default: {flag_mode}).
--updates POLICY Set the client updating policy. POLICY specifies
which updates Parity will auto-install:
track - All updates in the current release track.
patch - All updates of the current minor version.
critical - Only consensus/security updates.
none - No updates. Not recommended.
--no-consensus Force the binary to run even if there are known
issues regarding consensus. Not recommended.
--mode-timeout SECS Specify the number of seconds before inactivity
timeout occurs when mode is dark or passive
(default: {flag_mode_timeout}).

View File

@@ -684,7 +684,7 @@ mod tests {
use super::*;
use cli::Args;
use ethcore_rpc::NetworkSettings;
use ethcore::client::{VMType, BlockID};
use ethcore::client::{VMType, BlockId};
use ethcore::miner::{MinerOptions, PrioritizationStrategy};
use helpers::{replace_home, default_network_config};
use run::RunCmd;
@@ -792,8 +792,8 @@ mod tests {
wal: true,
tracing: Default::default(),
fat_db: Default::default(),
from_block: BlockID::Number(1),
to_block: BlockID::Latest,
from_block: BlockId::Number(1),
to_block: BlockId::Latest,
check_seal: true,
})));
}
@@ -814,8 +814,8 @@ mod tests {
wal: true,
tracing: Default::default(),
fat_db: Default::default(),
from_block: BlockID::Number(1),
to_block: BlockID::Latest,
from_block: BlockId::Number(1),
to_block: BlockId::Latest,
check_seal: true,
})));
}

View File

@@ -106,7 +106,7 @@ mod server {
use util::{Bytes, Address, U256};
use ethcore::transaction::{Transaction, Action};
use ethcore::client::{Client, BlockChainClient, BlockID};
use ethcore::client::{Client, BlockChainClient, BlockId};
use rpc_apis;
use ethcore_rpc::is_major_importing;
@@ -182,7 +182,7 @@ mod server {
data: data,
}.fake_sign(from);
self.client.call(&transaction, BlockID::Latest, Default::default())
self.client.call(&transaction, BlockId::Latest, Default::default())
.map_err(|e| format!("{:?}", e))
.map(|executed| {
executed.output

View File

@@ -20,7 +20,7 @@ use std::time::Duration;
use std::fs::File;
use util::{clean_0x, U256, Uint, Address, path, CompactionProfile};
use util::journaldb::Algorithm;
use ethcore::client::{Mode, BlockID, VMType, DatabaseCompactionProfile, ClientConfig, VerifierType};
use ethcore::client::{Mode, BlockId, VMType, DatabaseCompactionProfile, ClientConfig, VerifierType};
use ethcore::miner::{PendingSet, GasLimit, PrioritizationStrategy};
use cache::CacheConfig;
use dir::DatabaseDirectories;
@@ -62,13 +62,13 @@ pub fn to_mode(s: &str, timeout: u64, alarm: u64) -> Result<Mode, String> {
}
}
pub fn to_block_id(s: &str) -> Result<BlockID, String> {
pub fn to_block_id(s: &str) -> Result<BlockId, String> {
if s == "latest" {
Ok(BlockID::Latest)
Ok(BlockId::Latest)
} else if let Ok(num) = s.parse() {
Ok(BlockID::Number(num))
Ok(BlockId::Number(num))
} else if let Ok(hash) = s.parse() {
Ok(BlockID::Hash(hash))
Ok(BlockId::Hash(hash))
} else {
Err("Invalid block.".into())
}
@@ -327,7 +327,7 @@ mod tests {
use std::io::Write;
use devtools::RandomTempPath;
use util::{U256};
use ethcore::client::{Mode, BlockID};
use ethcore::client::{Mode, BlockId};
use ethcore::miner::PendingSet;
use super::{to_duration, to_mode, to_block_id, to_u256, to_pending_set, to_address, to_addresses, to_price, geth_ipc_path, to_bootnodes, password_from_file};
@@ -361,13 +361,13 @@ mod tests {
#[test]
fn test_to_block_id() {
assert_eq!(to_block_id("latest").unwrap(), BlockID::Latest);
assert_eq!(to_block_id("0").unwrap(), BlockID::Number(0));
assert_eq!(to_block_id("2").unwrap(), BlockID::Number(2));
assert_eq!(to_block_id("15").unwrap(), BlockID::Number(15));
assert_eq!(to_block_id("latest").unwrap(), BlockId::Latest);
assert_eq!(to_block_id("0").unwrap(), BlockId::Number(0));
assert_eq!(to_block_id("2").unwrap(), BlockId::Number(2));
assert_eq!(to_block_id("15").unwrap(), BlockId::Number(15));
assert_eq!(
to_block_id("9fc84d84f6a785dc1bd5abacfcf9cbdd3b6afb80c0f799bfb2fd42c44a0c224e").unwrap(),
BlockID::Hash("9fc84d84f6a785dc1bd5abacfcf9cbdd3b6afb80c0f799bfb2fd42c44a0c224e".parse().unwrap())
BlockId::Hash("9fc84d84f6a785dc1bd5abacfcf9cbdd3b6afb80c0f799bfb2fd42c44a0c224e".parse().unwrap())
);
}

View File

@@ -184,12 +184,12 @@ impl ChainNotify for Informant {
let ripe = Instant::now() > *last_import + Duration::from_secs(1) && !importing;
let txs_imported = imported.iter()
.take(imported.len() - if ripe {1} else {0})
.filter_map(|h| self.client.block(BlockID::Hash(*h)))
.filter_map(|h| self.client.block(BlockId::Hash(*h)))
.map(|b| BlockView::new(&b).transactions_count())
.sum();
if ripe {
if let Some(block) = imported.last().and_then(|h| self.client.block(BlockID::Hash(*h))) {
if let Some(block) = imported.last().and_then(|h| self.client.block(BlockId::Hash(*h))) {
let view = BlockView::new(&block);
let header = view.header();
let tx_count = view.transactions_count();

View File

@@ -26,7 +26,7 @@ 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::ids::BlockId;
use cache::CacheConfig;
use params::{SpecType, Pruning, Switch, tracing_switch_to_bool, fatdb_switch_to_bool};
@@ -60,7 +60,7 @@ pub struct SnapshotCommand {
pub file_path: Option<String>,
pub wal: bool,
pub kind: Kind,
pub block_at: BlockID,
pub block_at: BlockId,
}
// helper for reading chunks from arbitrary reader and feeding them into the