diff --git a/Cargo.lock b/Cargo.lock index 300929e6e..d5e7fab1e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -581,6 +581,7 @@ dependencies = [ "rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "semver 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "sha3 0.1.0", "table 0.1.0", "target_info 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1574,6 +1575,23 @@ dependencies = [ "nom 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "semver" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "semver-parser 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "semver-parser" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 0.1.68 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "serde" version = "0.8.4" @@ -2112,6 +2130,8 @@ dependencies = [ "checksum rustls 0.1.2 (git+https://github.com/ctz/rustls)" = "" "checksum semver 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)" = "d4f410fedcf71af0345d7607d246e7ad15faaadd49d240ee3b24e5dc21a820ac" "checksum semver 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2d5b7638a1f03815d94e88cb3b3c08e87f0db4d683ef499d1836aaf70a45623f" +"checksum semver 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ae2ff60ecdb19c255841c066cbfa5f8c2a4ada1eb3ae47c77ab6667128da71f5" +"checksum semver-parser 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e88e43a5a74dd2a11707f9c21dfd4a423c66bd871df813227bb0a3e78f3a1ae9" "checksum serde 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b1dfda9ebb31d29fa8b94d7eb3031a86a8dcec065f0fe268a30f98867bf45775" "checksum serde_codegen 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)" = "e422ae53d7933f59c6ff57e7b5870b5c9094b1f473f78ec33d89f8a692c3ec02" "checksum serde_codegen_internals 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f877e2781ed0a323295d1c9f0e26556117b5a11489fc47b1848dfb98b3173d21" diff --git a/ethcore/light/src/client.rs b/ethcore/light/src/client.rs index e3b5745b2..3a7706bef 100644 --- a/ethcore/light/src/client.rs +++ b/ethcore/light/src/client.rs @@ -20,7 +20,7 @@ use std::sync::Arc; use ethcore::engines::Engine; -use ethcore::ids::BlockID; +use ethcore::ids::BlockId; use ethcore::service::ClientIoMessage; use ethcore::block_import_error::BlockImportError; use ethcore::block_status::BlockStatus; @@ -51,7 +51,7 @@ impl Client { } /// Whether the block is already known (but not necessarily part of the canonical chain) - pub fn is_known(&self, _id: BlockID) -> bool { + pub fn is_known(&self, _id: BlockId) -> bool { false } @@ -61,7 +61,7 @@ impl Client { } /// Inquire about the status of a given block. - pub fn status(&self, _id: BlockID) -> BlockStatus { + pub fn status(&self, _id: BlockId) -> BlockStatus { BlockStatus::Unknown } diff --git a/ethcore/src/client/client.rs b/ethcore/src/client/client.rs index 66fad24d2..a4fa5aa57 100644 --- a/ethcore/src/client/client.rs +++ b/ethcore/src/client/client.rs @@ -52,7 +52,7 @@ use log_entry::LocalizedLogEntry; use verification::queue::BlockQueue; use blockchain::{BlockChain, BlockProvider, TreeRoute, ImportRoute}; use client::{ - BlockID, TransactionID, UncleID, TraceId, ClientConfig, BlockChainClient, + BlockId, TransactionId, UncleId, TraceId, ClientConfig, BlockChainClient, MiningBlockChainClient, TraceFilter, CallAnalytics, BlockImportError, Mode, ChainNotify, }; @@ -594,13 +594,13 @@ impl Client { /// Attempt to get a copy of a specific block's final state. /// - /// This will not fail if given BlockID::Latest. + /// This will not fail if given BlockId::Latest. /// Otherwise, this can fail (but may not) if the DB prunes state. - pub fn state_at(&self, id: BlockID) -> Option { + pub fn state_at(&self, id: BlockId) -> Option { // fast path for latest state. match id.clone() { - BlockID::Pending => return self.miner.pending_state().or_else(|| Some(self.state())), - BlockID::Latest => return Some(self.state()), + BlockId::Pending => return self.miner.pending_state().or_else(|| Some(self.state())), + BlockId::Latest => return Some(self.state()), _ => {}, } @@ -625,15 +625,15 @@ impl Client { /// Attempt to get a copy of a specific block's beginning state. /// - /// This will not fail if given BlockID::Latest. + /// This will not fail if given BlockId::Latest. /// Otherwise, this can fail (but may not) if the DB prunes state. - pub fn state_at_beginning(&self, id: BlockID) -> Option { + pub fn state_at_beginning(&self, id: BlockId) -> Option { // fast path for latest state. match id { - BlockID::Pending => self.state_at(BlockID::Latest), + BlockId::Pending => self.state_at(BlockId::Latest), id => match self.block_number(id) { None | Some(0) => None, - Some(n) => self.state_at(BlockID::Number(n - 1)), + Some(n) => self.state_at(BlockId::Number(n - 1)), } } } @@ -724,30 +724,31 @@ impl Client { data: data, }.fake_sign(from); - self.call(&transaction, BlockID::Latest, Default::default()) + self.call(&transaction, BlockId::Latest, Default::default()) .map_err(|e| format!("{:?}", e)) .map(|executed| { executed.output }) } + /// Get the updater object. pub fn updater(&self) -> MutexGuard> { self.updater.lock() } - /// Look up the block number for the given block ID. - pub fn block_number(&self, id: BlockID) -> Option { + /// Look up the block number for the given block Id. + pub fn block_number(&self, id: BlockId) -> Option { match id { - BlockID::Number(number) => Some(number), - BlockID::Hash(ref hash) => self.chain.read().block_number(hash), - BlockID::Earliest => Some(0), - BlockID::Latest | BlockID::Pending => Some(self.chain.read().best_block_number()), + BlockId::Number(number) => Some(number), + BlockId::Hash(ref hash) => self.chain.read().block_number(hash), + BlockId::Earliest => Some(0), + BlockId::Latest | BlockId::Pending => Some(self.chain.read().best_block_number()), } } /// Take a snapshot at the given block. - /// If the ID given is "latest", this will default to 1000 blocks behind. - pub fn take_snapshot(&self, writer: W, at: BlockID, p: &snapshot::Progress) -> Result<(), EthcoreError> { + /// If the Id given is "latest", this will default to 1000 blocks behind. + pub fn take_snapshot(&self, writer: W, at: BlockId, p: &snapshot::Progress) -> Result<(), EthcoreError> { let db = self.state_db.lock().journal_db().boxed_clone(); let best_block_number = self.chain_info().best_block_number; let block_number = try!(self.block_number(at).ok_or(snapshot::Error::InvalidStartingBlock(at))); @@ -759,13 +760,13 @@ impl Client { let history = ::std::cmp::min(self.history, 1000); let start_hash = match at { - BlockID::Latest => { + BlockId::Latest => { let start_num = match db.earliest_era() { Some(era) => ::std::cmp::max(era, best_block_number - history), None => best_block_number - history, }; - match self.block_hash(BlockID::Number(start_num)) { + match self.block_hash(BlockId::Number(start_num)) { Some(h) => h, None => return Err(snapshot::Error::InvalidStartingBlock(at).into()), } @@ -786,19 +787,19 @@ impl Client { self.history } - fn block_hash(chain: &BlockChain, id: BlockID) -> Option { + fn block_hash(chain: &BlockChain, id: BlockId) -> Option { match id { - BlockID::Hash(hash) => Some(hash), - BlockID::Number(number) => chain.block_hash(number), - BlockID::Earliest => chain.block_hash(0), - BlockID::Latest | BlockID::Pending => Some(chain.best_block_hash()), + BlockId::Hash(hash) => Some(hash), + BlockId::Number(number) => chain.block_hash(number), + BlockId::Earliest => chain.block_hash(0), + BlockId::Latest | BlockId::Pending => Some(chain.best_block_hash()), } } - fn transaction_address(&self, id: TransactionID) -> Option { + fn transaction_address(&self, id: TransactionId) -> Option { match id { - TransactionID::Hash(ref hash) => self.chain.read().transaction_address(hash), - TransactionID::Location(id, index) => Self::block_hash(&self.chain.read(), id).map(|hash| TransactionAddress { + TransactionId::Hash(ref hash) => self.chain.read().transaction_address(hash), + TransactionId::Location(id, index) => Self::block_hash(&self.chain.read(), id).map(|hash| TransactionAddress { block_hash: hash, index: index, }) @@ -852,7 +853,7 @@ impl snapshot::DatabaseRestore for Client { impl BlockChainClient for Client { - fn call(&self, t: &SignedTransaction, block: BlockID, analytics: CallAnalytics) -> Result { + fn call(&self, t: &SignedTransaction, block: BlockId, analytics: CallAnalytics) -> Result { let header = try!(self.block_header(block).ok_or(CallError::StatePruned)); let view = HeaderView::new(&header); let last_hashes = self.build_last_hashes(view.parent_hash()); @@ -888,11 +889,11 @@ impl BlockChainClient for Client { Ok(ret) } - fn replay(&self, id: TransactionID, analytics: CallAnalytics) -> Result { + fn replay(&self, id: TransactionId, analytics: CallAnalytics) -> Result { let address = try!(self.transaction_address(id).ok_or(CallError::TransactionNotFound)); - let header_data = try!(self.block_header(BlockID::Hash(address.block_hash)).ok_or(CallError::StatePruned)); - let body_data = try!(self.block_body(BlockID::Hash(address.block_hash)).ok_or(CallError::StatePruned)); - let mut state = try!(self.state_at_beginning(BlockID::Hash(address.block_hash)).ok_or(CallError::StatePruned)); + let header_data = try!(self.block_header(BlockId::Hash(address.block_hash)).ok_or(CallError::StatePruned)); + let body_data = try!(self.block_body(BlockId::Hash(address.block_hash)).ok_or(CallError::StatePruned)); + let mut state = try!(self.state_at_beginning(BlockId::Hash(address.block_hash)).ok_or(CallError::StatePruned)); let txs = BodyView::new(&body_data).transactions(); if address.index >= txs.len() { @@ -965,18 +966,18 @@ impl BlockChainClient for Client { self.chain.read().best_block_header() } - fn block_header(&self, id: BlockID) -> Option { + fn block_header(&self, id: BlockId) -> Option { let chain = self.chain.read(); Self::block_hash(&chain, id).and_then(|hash| chain.block_header_data(&hash)) } - fn block_body(&self, id: BlockID) -> Option { + fn block_body(&self, id: BlockId) -> Option { let chain = self.chain.read(); Self::block_hash(&chain, id).and_then(|hash| chain.block_body(&hash)) } - fn block(&self, id: BlockID) -> Option { - if let BlockID::Pending = id { + fn block(&self, id: BlockId) -> Option { + if let BlockId::Pending = id { if let Some(block) = self.miner.pending_block() { return Some(block.rlp_bytes(Seal::Without)); } @@ -987,7 +988,7 @@ impl BlockChainClient for Client { }) } - fn block_status(&self, id: BlockID) -> BlockStatus { + fn block_status(&self, id: BlockId) -> BlockStatus { let chain = self.chain.read(); match Self::block_hash(&chain, id) { Some(ref hash) if chain.is_known(hash) => BlockStatus::InChain, @@ -996,38 +997,38 @@ impl BlockChainClient for Client { } } - fn block_total_difficulty(&self, id: BlockID) -> Option { - if let BlockID::Pending = id { + fn block_total_difficulty(&self, id: BlockId) -> Option { + if let BlockId::Pending = id { if let Some(block) = self.miner.pending_block() { - return Some(*block.header.difficulty() + self.block_total_difficulty(BlockID::Latest).expect("blocks in chain have details; qed")); + return Some(*block.header.difficulty() + self.block_total_difficulty(BlockId::Latest).expect("blocks in chain have details; qed")); } } let chain = self.chain.read(); Self::block_hash(&chain, id).and_then(|hash| chain.block_details(&hash)).map(|d| d.total_difficulty) } - fn nonce(&self, address: &Address, id: BlockID) -> Option { + fn nonce(&self, address: &Address, id: BlockId) -> Option { self.state_at(id).map(|s| s.nonce(address)) } - fn block_hash(&self, id: BlockID) -> Option { + fn block_hash(&self, id: BlockId) -> Option { let chain = self.chain.read(); Self::block_hash(&chain, id) } - fn code(&self, address: &Address, id: BlockID) -> Option> { + fn code(&self, address: &Address, id: BlockId) -> Option> { self.state_at(id).map(|s| s.code(address).map(|c| (*c).clone())) } - fn balance(&self, address: &Address, id: BlockID) -> Option { + fn balance(&self, address: &Address, id: BlockId) -> Option { self.state_at(id).map(|s| s.balance(address)) } - fn storage_at(&self, address: &Address, position: &H256, id: BlockID) -> Option { + fn storage_at(&self, address: &Address, position: &H256, id: BlockId) -> Option { self.state_at(id).map(|s| s.storage_at(address, position)) } - fn list_accounts(&self, id: BlockID) -> Option> { + fn list_accounts(&self, id: BlockId) -> Option> { if !self.factories.trie.is_fat() { trace!(target: "fatdb", "list_accounts: Not a fat DB"); return None; @@ -1059,16 +1060,16 @@ impl BlockChainClient for Client { Some(accounts) } - fn transaction(&self, id: TransactionID) -> Option { + fn transaction(&self, id: TransactionId) -> Option { self.transaction_address(id).and_then(|address| self.chain.read().transaction(&address)) } - fn uncle(&self, id: UncleID) -> Option { + fn uncle(&self, id: UncleId) -> Option { let index = id.position; self.block_body(id.block).and_then(|body| BodyView::new(&body).uncle_rlp_at(index)) } - fn transaction_receipt(&self, id: TransactionID) -> Option { + fn transaction_receipt(&self, id: TransactionId) -> Option { let chain = self.chain.read(); self.transaction_address(id) .and_then(|address| chain.block_number(&address.block_hash).and_then(|block_number| { @@ -1152,7 +1153,7 @@ impl BlockChainClient for Client { if self.chain.read().is_known(&unverified.hash()) { return Err(BlockImportError::Import(ImportError::AlreadyInChain)); } - if self.block_status(BlockID::Hash(unverified.parent_hash())) == BlockStatus::Unknown { + if self.block_status(BlockId::Hash(unverified.parent_hash())) == BlockStatus::Unknown { return Err(BlockImportError::Block(BlockError::UnknownParent(unverified.parent_hash()))); } } @@ -1166,7 +1167,7 @@ impl BlockChainClient for Client { if self.chain.read().is_known(&header.hash()) { return Err(BlockImportError::Import(ImportError::AlreadyInChain)); } - if self.block_status(BlockID::Hash(header.parent_hash())) == BlockStatus::Unknown { + if self.block_status(BlockId::Hash(header.parent_hash())) == BlockStatus::Unknown { return Err(BlockImportError::Block(BlockError::UnknownParent(header.parent_hash()))); } } @@ -1189,7 +1190,7 @@ impl BlockChainClient for Client { self.engine.additional_params().into_iter().collect() } - fn blocks_with_bloom(&self, bloom: &H2048, from_block: BlockID, to_block: BlockID) -> Option> { + fn blocks_with_bloom(&self, bloom: &H2048, from_block: BlockId, to_block: BlockId) -> Option> { match (self.block_number(from_block), self.block_number(to_block)) { (Some(from), Some(to)) => Some(self.chain.read().blocks_with_bloom(bloom, from, to)), _ => None @@ -1231,20 +1232,20 @@ impl BlockChainClient for Client { let trace_address = trace.address; self.transaction_address(trace.transaction) .and_then(|tx_address| { - self.block_number(BlockID::Hash(tx_address.block_hash)) + self.block_number(BlockId::Hash(tx_address.block_hash)) .and_then(|number| self.tracedb.read().trace(number, tx_address.index, trace_address)) }) } - fn transaction_traces(&self, transaction: TransactionID) -> Option> { + fn transaction_traces(&self, transaction: TransactionId) -> Option> { self.transaction_address(transaction) .and_then(|tx_address| { - self.block_number(BlockID::Hash(tx_address.block_hash)) + self.block_number(BlockId::Hash(tx_address.block_hash)) .and_then(|number| self.tracedb.read().transaction_traces(number, tx_address.index)) }) } - fn block_traces(&self, block: BlockID) -> Option> { + fn block_traces(&self, block: BlockId) -> Option> { self.block_number(block) .and_then(|number| self.tracedb.read().block_traces(number)) } @@ -1279,13 +1280,13 @@ impl BlockChainClient for Client { self.engine.signing_network_id(&self.latest_env_info()) } - fn block_extra_info(&self, id: BlockID) -> Option> { + fn block_extra_info(&self, id: BlockId) -> Option> { self.block_header(id) .map(|block| decode(&block)) .map(|header| self.engine.extra_info(&header)) } - fn uncle_extra_info(&self, id: UncleID) -> Option> { + fn uncle_extra_info(&self, id: UncleId) -> Option> { self.uncle(id) .map(|header| self.engine.extra_info(&decode(&header))) } diff --git a/ethcore/src/client/operations.rs b/ethcore/src/client/operations.rs index 3141f1c25..e0408cdb0 100644 --- a/ethcore/src/client/operations.rs +++ b/ethcore/src/client/operations.rs @@ -14,26 +14,14 @@ pub struct Operations { impl Operations { pub fn new(address: util::Address, do_call: F) -> Self where F: Fn(util::Address, Vec) -> Result, String> + Send + 'static { Operations { - contract: ethabi::Contract::new(ethabi::Interface::load(b"[{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"address\"}],\"name\":\"owners\",\"outputs\":[{\"name\":\"\",\"type\":\"bytes32\"}],\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_client\",\"type\":\"bytes32\"},{\"name\":\"_newOwner\",\"type\":\"address\"}],\"name\":\"resetClientOwner\",\"outputs\":[],\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_client\",\"type\":\"bytes32\"},{\"name\":\"_release\",\"type\":\"bytes32\"}],\"name\":\"isLatest\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_client\",\"type\":\"bytes32\"},{\"name\":\"_release\",\"type\":\"bytes32\"}],\"name\":\"findRelease\",\"outputs\":[{\"name\":\"o_forkBlock\",\"type\":\"uint32\"},{\"name\":\"o_track\",\"type\":\"uint8\"},{\"name\":\"o_semver\",\"type\":\"uint24\"}],\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_txid\",\"type\":\"bytes32\"}],\"name\":\"rejectTransaction\",\"outputs\":[],\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_newOwner\",\"type\":\"address\"}],\"name\":\"setOwner\",\"outputs\":[],\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_client\",\"type\":\"bytes32\"}],\"name\":\"removeClient\",\"outputs\":[],\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"rejectFork\",\"outputs\":[],\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_client\",\"type\":\"bytes32\"},{\"name\":\"_checksum\",\"type\":\"bytes32\"}],\"name\":\"findBuild\",\"outputs\":[{\"name\":\"o_release\",\"type\":\"bytes32\"},{\"name\":\"o_platform\",\"type\":\"bytes32\"}],\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_number\",\"type\":\"uint32\"},{\"name\":\"_name\",\"type\":\"bytes32\"},{\"name\":\"_spec\",\"type\":\"bytes32\"}],\"name\":\"proposeFork\",\"outputs\":[],\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_newOwner\",\"type\":\"address\"}],\"name\":\"setClientOwner\",\"outputs\":[],\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_release\",\"type\":\"bytes32\"},{\"name\":\"_platform\",\"type\":\"bytes32\"},{\"name\":\"_checksum\",\"type\":\"bytes32\"}],\"name\":\"addChecksum\",\"outputs\":[],\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_txid\",\"type\":\"bytes32\"}],\"name\":\"confirmTransaction\",\"outputs\":[{\"name\":\"txSuccess\",\"type\":\"uint256\"}],\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"proxy\",\"outputs\":[{\"name\":\"requiredCount\",\"type\":\"uint256\"},{\"name\":\"to\",\"type\":\"address\"},{\"name\":\"data\",\"type\":\"bytes\"},{\"name\":\"value\",\"type\":\"uint256\"},{\"name\":\"gas\",\"type\":\"uint256\"}],\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_client\",\"type\":\"bytes32\"},{\"name\":\"_owner\",\"type\":\"address\"}],\"name\":\"addClient\",\"outputs\":[],\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint32\"}],\"name\":\"forks\",\"outputs\":[{\"name\":\"name\",\"type\":\"bytes32\"},{\"name\":\"spec\",\"type\":\"bytes32\"},{\"name\":\"ratified\",\"type\":\"bool\"},{\"name\":\"requiredCount\",\"type\":\"uint256\"}],\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_txid\",\"type\":\"bytes32\"},{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_data\",\"type\":\"bytes\"},{\"name\":\"_value\",\"type\":\"uint256\"},{\"name\":\"_gas\",\"type\":\"uint256\"}],\"name\":\"proposeTransaction\",\"outputs\":[{\"name\":\"txSuccess\",\"type\":\"uint256\"}],\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"acceptFork\",\"outputs\":[],\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_client\",\"type\":\"bytes32\"},{\"name\":\"_release\",\"type\":\"bytes32\"},{\"name\":\"_platform\",\"type\":\"bytes32\"}],\"name\":\"findChecksum\",\"outputs\":[{\"name\":\"\",\"type\":\"bytes32\"}],\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"clientsRequired\",\"outputs\":[{\"name\":\"\",\"type\":\"uint32\"}],\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_client\",\"type\":\"bytes32\"},{\"name\":\"_release\",\"type\":\"bytes32\"}],\"name\":\"track\",\"outputs\":[{\"name\":\"\",\"type\":\"uint8\"}],\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_client\",\"type\":\"bytes32\"},{\"name\":\"_r\",\"type\":\"bool\"}],\"name\":\"setClientRequired\",\"outputs\":[],\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_release\",\"type\":\"bytes32\"},{\"name\":\"_forkBlock\",\"type\":\"uint32\"},{\"name\":\"_track\",\"type\":\"uint8\"},{\"name\":\"_semver\",\"type\":\"uint24\"}],\"name\":\"addRelease\",\"outputs\":[],\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"latestFork\",\"outputs\":[{\"name\":\"\",\"type\":\"uint32\"}],\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_client\",\"type\":\"bytes32\"},{\"name\":\"_track\",\"type\":\"uint8\"}],\"name\":\"latestInTrack\",\"outputs\":[{\"name\":\"\",\"type\":\"bytes32\"}],\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"clients\",\"outputs\":[{\"name\":\"owner\",\"type\":\"address\"},{\"name\":\"required\",\"type\":\"bool\"}],\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"proposedFork\",\"outputs\":[{\"name\":\"\",\"type\":\"uint32\"}],\"type\":\"function\"},{\"inputs\":[],\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"from\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"value\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"Received\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"client\",\"type\":\"bytes32\"},{\"indexed\":true,\"name\":\"txid\",\"type\":\"bytes32\"},{\"indexed\":true,\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"data\",\"type\":\"bytes\"},{\"indexed\":false,\"name\":\"value\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"gas\",\"type\":\"uint256\"}],\"name\":\"TransactionProposed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"client\",\"type\":\"bytes32\"},{\"indexed\":true,\"name\":\"txid\",\"type\":\"bytes32\"}],\"name\":\"TransactionConfirmed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"client\",\"type\":\"bytes32\"},{\"indexed\":true,\"name\":\"txid\",\"type\":\"bytes32\"}],\"name\":\"TransactionRejected\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"txid\",\"type\":\"bytes32\"},{\"indexed\":false,\"name\":\"success\",\"type\":\"bool\"}],\"name\":\"TransactionRelayed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"client\",\"type\":\"bytes32\"},{\"indexed\":true,\"name\":\"number\",\"type\":\"uint32\"},{\"indexed\":true,\"name\":\"name\",\"type\":\"bytes32\"},{\"indexed\":false,\"name\":\"spec\",\"type\":\"bytes32\"}],\"name\":\"ForkProposed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"client\",\"type\":\"bytes32\"},{\"indexed\":true,\"name\":\"number\",\"type\":\"uint32\"}],\"name\":\"ForkAcceptedBy\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"client\",\"type\":\"bytes32\"},{\"indexed\":true,\"name\":\"number\",\"type\":\"uint32\"}],\"name\":\"ForkRejectedBy\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"forkNumber\",\"type\":\"uint32\"}],\"name\":\"ForkRejected\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"forkNumber\",\"type\":\"uint32\"}],\"name\":\"ForkRatified\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"client\",\"type\":\"bytes32\"},{\"indexed\":true,\"name\":\"forkBlock\",\"type\":\"uint32\"},{\"indexed\":true,\"name\":\"release\",\"type\":\"bytes32\"},{\"indexed\":false,\"name\":\"track\",\"type\":\"uint8\"},{\"indexed\":false,\"name\":\"semver\",\"type\":\"uint24\"}],\"name\":\"ReleaseAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"client\",\"type\":\"bytes32\"},{\"indexed\":true,\"name\":\"release\",\"type\":\"bytes32\"},{\"indexed\":true,\"name\":\"platform\",\"type\":\"bytes32\"},{\"indexed\":false,\"name\":\"checksum\",\"type\":\"bytes32\"}],\"name\":\"ChecksumAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"client\",\"type\":\"bytes32\"},{\"indexed\":false,\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"ClientAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"client\",\"type\":\"bytes32\"}],\"name\":\"ClientRemoved\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"client\",\"type\":\"bytes32\"},{\"indexed\":true,\"name\":\"old\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"now\",\"type\":\"address\"}],\"name\":\"ClientOwnerChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"client\",\"type\":\"bytes32\"},{\"indexed\":false,\"name\":\"now\",\"type\":\"bool\"}],\"name\":\"ClientRequiredChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"old\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"now\",\"type\":\"address\"}],\"name\":\"OwnerChanged\",\"type\":\"event\"}]").expect("JSON is autogenerated; qed")), + contract: ethabi::Contract::new(ethabi::Interface::load(b"[{\"constant\":false,\"inputs\":[{\"name\":\"_client\",\"type\":\"bytes32\"},{\"name\":\"_newOwner\",\"type\":\"address\"}],\"name\":\"resetClientOwner\",\"outputs\":[],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_client\",\"type\":\"bytes32\"},{\"name\":\"_release\",\"type\":\"bytes32\"}],\"name\":\"isLatest\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_txid\",\"type\":\"bytes32\"}],\"name\":\"rejectTransaction\",\"outputs\":[],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_newOwner\",\"type\":\"address\"}],\"name\":\"setOwner\",\"outputs\":[],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_number\",\"type\":\"uint32\"},{\"name\":\"_name\",\"type\":\"bytes32\"},{\"name\":\"_hard\",\"type\":\"bool\"},{\"name\":\"_spec\",\"type\":\"bytes32\"}],\"name\":\"proposeFork\",\"outputs\":[],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_client\",\"type\":\"bytes32\"}],\"name\":\"removeClient\",\"outputs\":[],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_client\",\"type\":\"bytes32\"},{\"name\":\"_release\",\"type\":\"bytes32\"}],\"name\":\"release\",\"outputs\":[{\"name\":\"o_forkBlock\",\"type\":\"uint32\"},{\"name\":\"o_track\",\"type\":\"uint8\"},{\"name\":\"o_semver\",\"type\":\"uint24\"},{\"name\":\"o_critical\",\"type\":\"bool\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_client\",\"type\":\"bytes32\"},{\"name\":\"_checksum\",\"type\":\"bytes32\"}],\"name\":\"build\",\"outputs\":[{\"name\":\"o_release\",\"type\":\"bytes32\"},{\"name\":\"o_platform\",\"type\":\"bytes32\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"rejectFork\",\"outputs\":[],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"client\",\"outputs\":[{\"name\":\"owner\",\"type\":\"address\"},{\"name\":\"required\",\"type\":\"bool\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_newOwner\",\"type\":\"address\"}],\"name\":\"setClientOwner\",\"outputs\":[],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint32\"}],\"name\":\"fork\",\"outputs\":[{\"name\":\"name\",\"type\":\"bytes32\"},{\"name\":\"spec\",\"type\":\"bytes32\"},{\"name\":\"hard\",\"type\":\"bool\"},{\"name\":\"ratified\",\"type\":\"bool\"},{\"name\":\"requiredCount\",\"type\":\"uint256\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_release\",\"type\":\"bytes32\"},{\"name\":\"_platform\",\"type\":\"bytes32\"},{\"name\":\"_checksum\",\"type\":\"bytes32\"}],\"name\":\"addChecksum\",\"outputs\":[],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_txid\",\"type\":\"bytes32\"}],\"name\":\"confirmTransaction\",\"outputs\":[{\"name\":\"txSuccess\",\"type\":\"uint256\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"proxy\",\"outputs\":[{\"name\":\"requiredCount\",\"type\":\"uint256\"},{\"name\":\"to\",\"type\":\"address\"},{\"name\":\"data\",\"type\":\"bytes\"},{\"name\":\"value\",\"type\":\"uint256\"},{\"name\":\"gas\",\"type\":\"uint256\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_client\",\"type\":\"bytes32\"},{\"name\":\"_owner\",\"type\":\"address\"}],\"name\":\"addClient\",\"outputs\":[],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"address\"}],\"name\":\"clientOwner\",\"outputs\":[{\"name\":\"\",\"type\":\"bytes32\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_txid\",\"type\":\"bytes32\"},{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_data\",\"type\":\"bytes\"},{\"name\":\"_value\",\"type\":\"uint256\"},{\"name\":\"_gas\",\"type\":\"uint256\"}],\"name\":\"proposeTransaction\",\"outputs\":[{\"name\":\"txSuccess\",\"type\":\"uint256\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"grandOwner\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_release\",\"type\":\"bytes32\"},{\"name\":\"_forkBlock\",\"type\":\"uint32\"},{\"name\":\"_track\",\"type\":\"uint8\"},{\"name\":\"_semver\",\"type\":\"uint24\"},{\"name\":\"_critical\",\"type\":\"bool\"}],\"name\":\"addRelease\",\"outputs\":[],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"acceptFork\",\"outputs\":[],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"clientsRequired\",\"outputs\":[{\"name\":\"\",\"type\":\"uint32\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_client\",\"type\":\"bytes32\"},{\"name\":\"_release\",\"type\":\"bytes32\"}],\"name\":\"track\",\"outputs\":[{\"name\":\"\",\"type\":\"uint8\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_client\",\"type\":\"bytes32\"},{\"name\":\"_r\",\"type\":\"bool\"}],\"name\":\"setClientRequired\",\"outputs\":[],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"latestFork\",\"outputs\":[{\"name\":\"\",\"type\":\"uint32\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_client\",\"type\":\"bytes32\"},{\"name\":\"_track\",\"type\":\"uint8\"}],\"name\":\"latestInTrack\",\"outputs\":[{\"name\":\"\",\"type\":\"bytes32\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_client\",\"type\":\"bytes32\"},{\"name\":\"_release\",\"type\":\"bytes32\"},{\"name\":\"_platform\",\"type\":\"bytes32\"}],\"name\":\"checksum\",\"outputs\":[{\"name\":\"\",\"type\":\"bytes32\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"proposedFork\",\"outputs\":[{\"name\":\"\",\"type\":\"uint32\"}],\"payable\":false,\"type\":\"function\"}]").expect("JSON is autogenerated; qed")), address: address, do_call: Box::new(do_call), } } fn as_string(e: T) -> String { format!("{:?}", e) } - /// Auto-generated from: `{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"owners","outputs":[{"name":"","type":"bytes32"}],"type":"function"}` - #[allow(dead_code)] - pub fn owners(&self, _1: &util::Address) -> Result { - let call = self.contract.function("owners".into()).map_err(Self::as_string)?; - let data = call.encode_call( - vec![ethabi::Token::Address(_1.clone().0)] - ).map_err(Self::as_string)?; - let output = call.decode_output((self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; - let mut result = output.into_iter().rev().collect::>(); - Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = try!(r.to_fixed_bytes().ok_or("Invalid type returned")); util::H256::from_slice(r.as_ref()) })) - } - - /// Auto-generated from: `{"constant":false,"inputs":[{"name":"_client","type":"bytes32"},{"name":"_newOwner","type":"address"}],"name":"resetClientOwner","outputs":[],"type":"function"}` + /// Auto-generated from: `{"constant":false,"inputs":[{"name":"_client","type":"bytes32"},{"name":"_newOwner","type":"address"}],"name":"resetClientOwner","outputs":[],"payable":false,"type":"function"}` #[allow(dead_code)] pub fn reset_client_owner(&self, _client: &str, _new_owner: &util::Address) -> Result<(), String> { let call = self.contract.function("resetClientOwner".into()).map_err(Self::as_string)?; @@ -45,7 +33,7 @@ impl Operations { Ok(()) } - /// Auto-generated from: `{"constant":true,"inputs":[{"name":"_client","type":"bytes32"},{"name":"_release","type":"bytes32"}],"name":"isLatest","outputs":[{"name":"","type":"bool"}],"type":"function"}` + /// Auto-generated from: `{"constant":true,"inputs":[{"name":"_client","type":"bytes32"},{"name":"_release","type":"bytes32"}],"name":"isLatest","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"}` #[allow(dead_code)] pub fn is_latest(&self, _client: &str, _release: &util::H256) -> Result { let call = self.contract.function("isLatest".into()).map_err(Self::as_string)?; @@ -57,20 +45,7 @@ impl Operations { Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = try!(r.to_bool().ok_or("Invalid type returned")); r })) } - /// Auto-generated from: `{"constant":true,"inputs":[{"name":"_client","type":"bytes32"},{"name":"_release","type":"bytes32"}],"name":"findRelease","outputs":[{"name":"o_forkBlock","type":"uint32"},{"name":"o_track","type":"uint8"},{"name":"o_semver","type":"uint24"}],"type":"function"}` - #[allow(dead_code)] - pub fn find_release(&self, _client: &str, _release: &util::H256) -> Result<(u32, u8, u32), String> { - let call = self.contract.function("findRelease".into()).map_err(Self::as_string)?; - let data = call.encode_call( - vec![ethabi::Token::FixedBytes(_client.as_bytes().to_owned()), ethabi::Token::FixedBytes(_release.as_ref().to_owned())] - ).map_err(Self::as_string)?; - let output = (self.do_call)(self.address.clone(), data)?; - let returned = call.decode_output(output).map_err(Self::as_string)?; - let mut result = returned.into_iter().rev().collect::>(); - Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = try!(r.to_uint().ok_or("Invalid type returned")); util::U256::from(r.as_ref()).as_u64() as u32 }, { let r = result.pop().ok_or("Invalid return arity")?; let r = try!(r.to_uint().ok_or("Invalid type returned")); util::U256::from(r.as_ref()).as_u64() as u8 }, { let r = result.pop().ok_or("Invalid return arity")?; let r = try!(r.to_uint().ok_or("Invalid type returned")); util::U256::from(r.as_ref()).as_u64() as u32 })) - } - - /// Auto-generated from: `{"constant":false,"inputs":[{"name":"_txid","type":"bytes32"}],"name":"rejectTransaction","outputs":[],"type":"function"}` + /// Auto-generated from: `{"constant":false,"inputs":[{"name":"_txid","type":"bytes32"}],"name":"rejectTransaction","outputs":[],"payable":false,"type":"function"}` #[allow(dead_code)] pub fn reject_transaction(&self, _txid: &util::H256) -> Result<(), String> { let call = self.contract.function("rejectTransaction".into()).map_err(Self::as_string)?; @@ -82,7 +57,7 @@ impl Operations { Ok(()) } - /// Auto-generated from: `{"constant":false,"inputs":[{"name":"_newOwner","type":"address"}],"name":"setOwner","outputs":[],"type":"function"}` + /// Auto-generated from: `{"constant":false,"inputs":[{"name":"_newOwner","type":"address"}],"name":"setOwner","outputs":[],"payable":false,"type":"function"}` #[allow(dead_code)] pub fn set_owner(&self, _new_owner: &util::Address) -> Result<(), String> { let call = self.contract.function("setOwner".into()).map_err(Self::as_string)?; @@ -94,7 +69,19 @@ impl Operations { Ok(()) } - /// Auto-generated from: `{"constant":false,"inputs":[{"name":"_client","type":"bytes32"}],"name":"removeClient","outputs":[],"type":"function"}` + /// Auto-generated from: `{"constant":false,"inputs":[{"name":"_number","type":"uint32"},{"name":"_name","type":"bytes32"},{"name":"_hard","type":"bool"},{"name":"_spec","type":"bytes32"}],"name":"proposeFork","outputs":[],"payable":false,"type":"function"}` + #[allow(dead_code)] + pub fn propose_fork(&self, _number: u32, _name: &util::H256, _hard: bool, _spec: &util::H256) -> Result<(), String> { + let call = self.contract.function("proposeFork".into()).map_err(Self::as_string)?; + let data = call.encode_call( + vec![ethabi::Token::Uint({ let mut r = [0u8; 32]; util::U256::from(_number as u64).to_big_endian(&mut r); r }), ethabi::Token::FixedBytes(_name.as_ref().to_owned()), ethabi::Token::Bool(_hard), ethabi::Token::FixedBytes(_spec.as_ref().to_owned())] + ).map_err(Self::as_string)?; + call.decode_output((self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; + + Ok(()) + } + + /// Auto-generated from: `{"constant":false,"inputs":[{"name":"_client","type":"bytes32"}],"name":"removeClient","outputs":[],"payable":false,"type":"function"}` #[allow(dead_code)] pub fn remove_client(&self, _client: &str) -> Result<(), String> { let call = self.contract.function("removeClient".into()).map_err(Self::as_string)?; @@ -106,7 +93,31 @@ impl Operations { Ok(()) } - /// Auto-generated from: `{"constant":false,"inputs":[],"name":"rejectFork","outputs":[],"type":"function"}` + /// Auto-generated from: `{"constant":true,"inputs":[{"name":"_client","type":"bytes32"},{"name":"_release","type":"bytes32"}],"name":"release","outputs":[{"name":"o_forkBlock","type":"uint32"},{"name":"o_track","type":"uint8"},{"name":"o_semver","type":"uint24"},{"name":"o_critical","type":"bool"}],"payable":false,"type":"function"}` + #[allow(dead_code)] + pub fn release(&self, _client: &str, _release: &util::H256) -> Result<(u32, u8, u32, bool), String> { + let call = self.contract.function("release".into()).map_err(Self::as_string)?; + let data = call.encode_call( + vec![ethabi::Token::FixedBytes(_client.as_bytes().to_owned()), ethabi::Token::FixedBytes(_release.as_ref().to_owned())] + ).map_err(Self::as_string)?; + let output = call.decode_output((self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; + let mut result = output.into_iter().rev().collect::>(); + Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = try!(r.to_uint().ok_or("Invalid type returned")); util::U256::from(r.as_ref()).as_u64() as u32 }, { let r = result.pop().ok_or("Invalid return arity")?; let r = try!(r.to_uint().ok_or("Invalid type returned")); util::U256::from(r.as_ref()).as_u64() as u8 }, { let r = result.pop().ok_or("Invalid return arity")?; let r = try!(r.to_uint().ok_or("Invalid type returned")); util::U256::from(r.as_ref()).as_u64() as u32 }, { let r = result.pop().ok_or("Invalid return arity")?; let r = try!(r.to_bool().ok_or("Invalid type returned")); r })) + } + + /// Auto-generated from: `{"constant":true,"inputs":[{"name":"_client","type":"bytes32"},{"name":"_checksum","type":"bytes32"}],"name":"build","outputs":[{"name":"o_release","type":"bytes32"},{"name":"o_platform","type":"bytes32"}],"payable":false,"type":"function"}` + #[allow(dead_code)] + pub fn build(&self, _client: &str, _checksum: &util::H256) -> Result<(util::H256, util::H256), String> { + let call = self.contract.function("build".into()).map_err(Self::as_string)?; + let data = call.encode_call( + vec![ethabi::Token::FixedBytes(_client.as_bytes().to_owned()), ethabi::Token::FixedBytes(_checksum.as_ref().to_owned())] + ).map_err(Self::as_string)?; + let output = call.decode_output((self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; + let mut result = output.into_iter().rev().collect::>(); + Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = try!(r.to_fixed_bytes().ok_or("Invalid type returned")); util::H256::from_slice(r.as_ref()) }, { let r = result.pop().ok_or("Invalid return arity")?; let r = try!(r.to_fixed_bytes().ok_or("Invalid type returned")); util::H256::from_slice(r.as_ref()) })) + } + + /// Auto-generated from: `{"constant":false,"inputs":[],"name":"rejectFork","outputs":[],"payable":false,"type":"function"}` #[allow(dead_code)] pub fn reject_fork(&self) -> Result<(), String> { let call = self.contract.function("rejectFork".into()).map_err(Self::as_string)?; @@ -118,31 +129,19 @@ impl Operations { Ok(()) } - /// Auto-generated from: `{"constant":true,"inputs":[{"name":"_client","type":"bytes32"},{"name":"_checksum","type":"bytes32"}],"name":"findBuild","outputs":[{"name":"o_release","type":"bytes32"},{"name":"o_platform","type":"bytes32"}],"type":"function"}` + /// Auto-generated from: `{"constant":true,"inputs":[{"name":"","type":"bytes32"}],"name":"client","outputs":[{"name":"owner","type":"address"},{"name":"required","type":"bool"}],"payable":false,"type":"function"}` #[allow(dead_code)] - pub fn find_build(&self, _client: &str, _checksum: &util::H256) -> Result<(util::H256, util::H256), String> { - let call = self.contract.function("findBuild".into()).map_err(Self::as_string)?; + pub fn client(&self, _1: &util::H256) -> Result<(util::Address, bool), String> { + let call = self.contract.function("client".into()).map_err(Self::as_string)?; let data = call.encode_call( - vec![ethabi::Token::FixedBytes(_client.as_bytes().to_owned()), ethabi::Token::FixedBytes(_checksum.as_ref().to_owned())] + vec![ethabi::Token::FixedBytes(_1.as_ref().to_owned())] ).map_err(Self::as_string)?; let output = call.decode_output((self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; let mut result = output.into_iter().rev().collect::>(); - Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = try!(r.to_fixed_bytes().ok_or("Invalid type returned")); util::H256::from_slice(r.as_ref()) }, { let r = result.pop().ok_or("Invalid return arity")?; let r = try!(r.to_fixed_bytes().ok_or("Invalid type returned")); util::H256::from_slice(r.as_ref()) })) + Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = try!(r.to_address().ok_or("Invalid type returned")); util::Address::from(r) }, { let r = result.pop().ok_or("Invalid return arity")?; let r = try!(r.to_bool().ok_or("Invalid type returned")); r })) } - /// Auto-generated from: `{"constant":false,"inputs":[{"name":"_number","type":"uint32"},{"name":"_name","type":"bytes32"},{"name":"_spec","type":"bytes32"}],"name":"proposeFork","outputs":[],"type":"function"}` - #[allow(dead_code)] - pub fn propose_fork(&self, _number: u32, _name: &util::H256, _spec: &util::H256) -> Result<(), String> { - let call = self.contract.function("proposeFork".into()).map_err(Self::as_string)?; - let data = call.encode_call( - vec![ethabi::Token::Uint({ let mut r = [0u8; 32]; util::U256::from(_number as u64).to_big_endian(&mut r); r }), ethabi::Token::FixedBytes(_name.as_ref().to_owned()), ethabi::Token::FixedBytes(_spec.as_ref().to_owned())] - ).map_err(Self::as_string)?; - call.decode_output((self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; - - Ok(()) - } - - /// Auto-generated from: `{"constant":false,"inputs":[{"name":"_newOwner","type":"address"}],"name":"setClientOwner","outputs":[],"type":"function"}` + /// Auto-generated from: `{"constant":false,"inputs":[{"name":"_newOwner","type":"address"}],"name":"setClientOwner","outputs":[],"payable":false,"type":"function"}` #[allow(dead_code)] pub fn set_client_owner(&self, _new_owner: &util::Address) -> Result<(), String> { let call = self.contract.function("setClientOwner".into()).map_err(Self::as_string)?; @@ -154,7 +153,19 @@ impl Operations { Ok(()) } - /// Auto-generated from: `{"constant":false,"inputs":[{"name":"_release","type":"bytes32"},{"name":"_platform","type":"bytes32"},{"name":"_checksum","type":"bytes32"}],"name":"addChecksum","outputs":[],"type":"function"}` + /// Auto-generated from: `{"constant":true,"inputs":[{"name":"","type":"uint32"}],"name":"fork","outputs":[{"name":"name","type":"bytes32"},{"name":"spec","type":"bytes32"},{"name":"hard","type":"bool"},{"name":"ratified","type":"bool"},{"name":"requiredCount","type":"uint256"}],"payable":false,"type":"function"}` + #[allow(dead_code)] + pub fn fork(&self, _1: u32) -> Result<(util::H256, util::H256, bool, bool, util::U256), String> { + let call = self.contract.function("fork".into()).map_err(Self::as_string)?; + let data = call.encode_call( + vec![ethabi::Token::Uint({ let mut r = [0u8; 32]; util::U256::from(_1 as u64).to_big_endian(&mut r); r })] + ).map_err(Self::as_string)?; + let output = call.decode_output((self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; + let mut result = output.into_iter().rev().collect::>(); + Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = try!(r.to_fixed_bytes().ok_or("Invalid type returned")); util::H256::from_slice(r.as_ref()) }, { let r = result.pop().ok_or("Invalid return arity")?; let r = try!(r.to_fixed_bytes().ok_or("Invalid type returned")); util::H256::from_slice(r.as_ref()) }, { let r = result.pop().ok_or("Invalid return arity")?; let r = try!(r.to_bool().ok_or("Invalid type returned")); r }, { let r = result.pop().ok_or("Invalid return arity")?; let r = try!(r.to_bool().ok_or("Invalid type returned")); r }, { let r = result.pop().ok_or("Invalid return arity")?; let r = try!(r.to_uint().ok_or("Invalid type returned")); util::U256::from(r.as_ref()) })) + } + + /// Auto-generated from: `{"constant":false,"inputs":[{"name":"_release","type":"bytes32"},{"name":"_platform","type":"bytes32"},{"name":"_checksum","type":"bytes32"}],"name":"addChecksum","outputs":[],"payable":false,"type":"function"}` #[allow(dead_code)] pub fn add_checksum(&self, _release: &util::H256, _platform: &str, _checksum: &util::H256) -> Result<(), String> { let call = self.contract.function("addChecksum".into()).map_err(Self::as_string)?; @@ -166,7 +177,7 @@ impl Operations { Ok(()) } - /// Auto-generated from: `{"constant":false,"inputs":[{"name":"_txid","type":"bytes32"}],"name":"confirmTransaction","outputs":[{"name":"txSuccess","type":"uint256"}],"type":"function"}` + /// Auto-generated from: `{"constant":false,"inputs":[{"name":"_txid","type":"bytes32"}],"name":"confirmTransaction","outputs":[{"name":"txSuccess","type":"uint256"}],"payable":false,"type":"function"}` #[allow(dead_code)] pub fn confirm_transaction(&self, _txid: &util::H256) -> Result { let call = self.contract.function("confirmTransaction".into()).map_err(Self::as_string)?; @@ -178,7 +189,7 @@ impl Operations { Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = try!(r.to_uint().ok_or("Invalid type returned")); util::U256::from(r.as_ref()) })) } - /// Auto-generated from: `{"constant":true,"inputs":[{"name":"","type":"bytes32"}],"name":"proxy","outputs":[{"name":"requiredCount","type":"uint256"},{"name":"to","type":"address"},{"name":"data","type":"bytes"},{"name":"value","type":"uint256"},{"name":"gas","type":"uint256"}],"type":"function"}` + /// Auto-generated from: `{"constant":true,"inputs":[{"name":"","type":"bytes32"}],"name":"proxy","outputs":[{"name":"requiredCount","type":"uint256"},{"name":"to","type":"address"},{"name":"data","type":"bytes"},{"name":"value","type":"uint256"},{"name":"gas","type":"uint256"}],"payable":false,"type":"function"}` #[allow(dead_code)] pub fn proxy(&self, _1: &util::H256) -> Result<(util::U256, util::Address, Vec, util::U256, util::U256), String> { let call = self.contract.function("proxy".into()).map_err(Self::as_string)?; @@ -190,7 +201,7 @@ impl Operations { Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = try!(r.to_uint().ok_or("Invalid type returned")); util::U256::from(r.as_ref()) }, { let r = result.pop().ok_or("Invalid return arity")?; let r = try!(r.to_address().ok_or("Invalid type returned")); util::Address::from(r) }, { let r = result.pop().ok_or("Invalid return arity")?; let r = try!(r.to_bytes().ok_or("Invalid type returned")); r }, { let r = result.pop().ok_or("Invalid return arity")?; let r = try!(r.to_uint().ok_or("Invalid type returned")); util::U256::from(r.as_ref()) }, { let r = result.pop().ok_or("Invalid return arity")?; let r = try!(r.to_uint().ok_or("Invalid type returned")); util::U256::from(r.as_ref()) })) } - /// Auto-generated from: `{"constant":false,"inputs":[{"name":"_client","type":"bytes32"},{"name":"_owner","type":"address"}],"name":"addClient","outputs":[],"type":"function"}` + /// Auto-generated from: `{"constant":false,"inputs":[{"name":"_client","type":"bytes32"},{"name":"_owner","type":"address"}],"name":"addClient","outputs":[],"payable":false,"type":"function"}` #[allow(dead_code)] pub fn add_client(&self, _client: &str, _owner: &util::Address) -> Result<(), String> { let call = self.contract.function("addClient".into()).map_err(Self::as_string)?; @@ -202,31 +213,19 @@ impl Operations { Ok(()) } - /// Auto-generated from: `{"constant":true,"inputs":[{"name":"","type":"uint32"}],"name":"forks","outputs":[{"name":"name","type":"bytes32"},{"name":"spec","type":"bytes32"},{"name":"ratified","type":"bool"},{"name":"requiredCount","type":"uint256"}],"type":"function"}` + /// Auto-generated from: `{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"clientOwner","outputs":[{"name":"","type":"bytes32"}],"payable":false,"type":"function"}` #[allow(dead_code)] - pub fn forks(&self, _1: u32) -> Result<(util::H256, util::H256, bool, util::U256), String> { - let call = self.contract.function("forks".into()).map_err(Self::as_string)?; + pub fn client_owner(&self, _1: &util::Address) -> Result { + let call = self.contract.function("clientOwner".into()).map_err(Self::as_string)?; let data = call.encode_call( - vec![ethabi::Token::Uint({ let mut r = [0u8; 32]; util::U256::from(_1 as u64).to_big_endian(&mut r); r })] + vec![ethabi::Token::Address(_1.clone().0)] ).map_err(Self::as_string)?; let output = call.decode_output((self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; let mut result = output.into_iter().rev().collect::>(); - Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = try!(r.to_fixed_bytes().ok_or("Invalid type returned")); util::H256::from_slice(r.as_ref()) }, { let r = result.pop().ok_or("Invalid return arity")?; let r = try!(r.to_fixed_bytes().ok_or("Invalid type returned")); util::H256::from_slice(r.as_ref()) }, { let r = result.pop().ok_or("Invalid return arity")?; let r = try!(r.to_bool().ok_or("Invalid type returned")); r }, { let r = result.pop().ok_or("Invalid return arity")?; let r = try!(r.to_uint().ok_or("Invalid type returned")); util::U256::from(r.as_ref()) })) + Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = try!(r.to_fixed_bytes().ok_or("Invalid type returned")); util::H256::from_slice(r.as_ref()) })) } - /// Auto-generated from: `{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"type":"function"}` - #[allow(dead_code)] - pub fn owner(&self) -> Result { - let call = self.contract.function("owner".into()).map_err(Self::as_string)?; - let data = call.encode_call( - vec![] - ).map_err(Self::as_string)?; - let output = call.decode_output((self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; - let mut result = output.into_iter().rev().collect::>(); - Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = try!(r.to_address().ok_or("Invalid type returned")); util::Address::from(r) })) - } - - /// Auto-generated from: `{"constant":false,"inputs":[{"name":"_txid","type":"bytes32"},{"name":"_to","type":"address"},{"name":"_data","type":"bytes"},{"name":"_value","type":"uint256"},{"name":"_gas","type":"uint256"}],"name":"proposeTransaction","outputs":[{"name":"txSuccess","type":"uint256"}],"type":"function"}` + /// Auto-generated from: `{"constant":false,"inputs":[{"name":"_txid","type":"bytes32"},{"name":"_to","type":"address"},{"name":"_data","type":"bytes"},{"name":"_value","type":"uint256"},{"name":"_gas","type":"uint256"}],"name":"proposeTransaction","outputs":[{"name":"txSuccess","type":"uint256"}],"payable":false,"type":"function"}` #[allow(dead_code)] pub fn propose_transaction(&self, _txid: &util::H256, _to: &util::Address, _data: &[u8], _value: util::U256, _gas: util::U256) -> Result { let call = self.contract.function("proposeTransaction".into()).map_err(Self::as_string)?; @@ -238,7 +237,31 @@ impl Operations { Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = try!(r.to_uint().ok_or("Invalid type returned")); util::U256::from(r.as_ref()) })) } - /// Auto-generated from: `{"constant":false,"inputs":[],"name":"acceptFork","outputs":[],"type":"function"}` + /// Auto-generated from: `{"constant":true,"inputs":[],"name":"grandOwner","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"}` + #[allow(dead_code)] + pub fn grand_owner(&self) -> Result { + let call = self.contract.function("grandOwner".into()).map_err(Self::as_string)?; + let data = call.encode_call( + vec![] + ).map_err(Self::as_string)?; + let output = call.decode_output((self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; + let mut result = output.into_iter().rev().collect::>(); + Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = try!(r.to_address().ok_or("Invalid type returned")); util::Address::from(r) })) + } + + /// Auto-generated from: `{"constant":false,"inputs":[{"name":"_release","type":"bytes32"},{"name":"_forkBlock","type":"uint32"},{"name":"_track","type":"uint8"},{"name":"_semver","type":"uint24"},{"name":"_critical","type":"bool"}],"name":"addRelease","outputs":[],"payable":false,"type":"function"}` + #[allow(dead_code)] + pub fn add_release(&self, _release: &util::H256, _fork_block: u32, _track: u8, _semver: u32, _critical: bool) -> Result<(), String> { + let call = self.contract.function("addRelease".into()).map_err(Self::as_string)?; + let data = call.encode_call( + vec![ethabi::Token::FixedBytes(_release.as_ref().to_owned()), ethabi::Token::Uint({ let mut r = [0u8; 32]; util::U256::from(_fork_block as u64).to_big_endian(&mut r); r }), ethabi::Token::Uint({ let mut r = [0u8; 32]; util::U256::from(_track as u64).to_big_endian(&mut r); r }), ethabi::Token::Uint({ let mut r = [0u8; 32]; util::U256::from(_semver as u64).to_big_endian(&mut r); r }), ethabi::Token::Bool(_critical)] + ).map_err(Self::as_string)?; + call.decode_output((self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; + + Ok(()) + } + + /// Auto-generated from: `{"constant":false,"inputs":[],"name":"acceptFork","outputs":[],"payable":false,"type":"function"}` #[allow(dead_code)] pub fn accept_fork(&self) -> Result<(), String> { let call = self.contract.function("acceptFork".into()).map_err(Self::as_string)?; @@ -250,19 +273,7 @@ impl Operations { Ok(()) } - /// Auto-generated from: `{"constant":true,"inputs":[{"name":"_client","type":"bytes32"},{"name":"_release","type":"bytes32"},{"name":"_platform","type":"bytes32"}],"name":"findChecksum","outputs":[{"name":"","type":"bytes32"}],"type":"function"}` - #[allow(dead_code)] - pub fn find_checksum(&self, _client: &str, _release: &util::H256, _platform: &str) -> Result { - let call = self.contract.function("findChecksum".into()).map_err(Self::as_string)?; - let data = call.encode_call( - vec![ethabi::Token::FixedBytes(_client.as_bytes().to_owned()), ethabi::Token::FixedBytes(_release.as_ref().to_owned()), ethabi::Token::FixedBytes(_platform.as_bytes().to_owned())] - ).map_err(Self::as_string)?; - let output = call.decode_output((self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; - let mut result = output.into_iter().rev().collect::>(); - Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = try!(r.to_fixed_bytes().ok_or("Invalid type returned")); util::H256::from_slice(r.as_ref()) })) - } - - /// Auto-generated from: `{"constant":true,"inputs":[],"name":"clientsRequired","outputs":[{"name":"","type":"uint32"}],"type":"function"}` + /// Auto-generated from: `{"constant":true,"inputs":[],"name":"clientsRequired","outputs":[{"name":"","type":"uint32"}],"payable":false,"type":"function"}` #[allow(dead_code)] pub fn clients_required(&self) -> Result { let call = self.contract.function("clientsRequired".into()).map_err(Self::as_string)?; @@ -274,7 +285,7 @@ impl Operations { Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = try!(r.to_uint().ok_or("Invalid type returned")); util::U256::from(r.as_ref()).as_u64() as u32 })) } - /// Auto-generated from: `{"constant":true,"inputs":[{"name":"_client","type":"bytes32"},{"name":"_release","type":"bytes32"}],"name":"track","outputs":[{"name":"","type":"uint8"}],"type":"function"}` + /// Auto-generated from: `{"constant":true,"inputs":[{"name":"_client","type":"bytes32"},{"name":"_release","type":"bytes32"}],"name":"track","outputs":[{"name":"","type":"uint8"}],"payable":false,"type":"function"}` #[allow(dead_code)] pub fn track(&self, _client: &str, _release: &util::H256) -> Result { let call = self.contract.function("track".into()).map_err(Self::as_string)?; @@ -286,7 +297,7 @@ impl Operations { Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = try!(r.to_uint().ok_or("Invalid type returned")); util::U256::from(r.as_ref()).as_u64() as u8 })) } - /// Auto-generated from: `{"constant":false,"inputs":[{"name":"_client","type":"bytes32"},{"name":"_r","type":"bool"}],"name":"setClientRequired","outputs":[],"type":"function"}` + /// Auto-generated from: `{"constant":false,"inputs":[{"name":"_client","type":"bytes32"},{"name":"_r","type":"bool"}],"name":"setClientRequired","outputs":[],"payable":false,"type":"function"}` #[allow(dead_code)] pub fn set_client_required(&self, _client: &str, _r: bool) -> Result<(), String> { let call = self.contract.function("setClientRequired".into()).map_err(Self::as_string)?; @@ -298,19 +309,7 @@ impl Operations { Ok(()) } - /// Auto-generated from: `{"constant":false,"inputs":[{"name":"_release","type":"bytes32"},{"name":"_forkBlock","type":"uint32"},{"name":"_track","type":"uint8"},{"name":"_semver","type":"uint24"}],"name":"addRelease","outputs":[],"type":"function"}` - #[allow(dead_code)] - pub fn add_release(&self, _release: &util::H256, _fork_block: u32, _track: u8, _semver: u32) -> Result<(), String> { - let call = self.contract.function("addRelease".into()).map_err(Self::as_string)?; - let data = call.encode_call( - vec![ethabi::Token::FixedBytes(_release.as_ref().to_owned()), ethabi::Token::Uint({ let mut r = [0u8; 32]; util::U256::from(_fork_block as u64).to_big_endian(&mut r); r }), ethabi::Token::Uint({ let mut r = [0u8; 32]; util::U256::from(_track as u64).to_big_endian(&mut r); r }), ethabi::Token::Uint({ let mut r = [0u8; 32]; util::U256::from(_semver as u64).to_big_endian(&mut r); r })] - ).map_err(Self::as_string)?; - call.decode_output((self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; - - Ok(()) - } - - /// Auto-generated from: `{"constant":true,"inputs":[],"name":"latestFork","outputs":[{"name":"","type":"uint32"}],"type":"function"}` + /// Auto-generated from: `{"constant":true,"inputs":[],"name":"latestFork","outputs":[{"name":"","type":"uint32"}],"payable":false,"type":"function"}` #[allow(dead_code)] pub fn latest_fork(&self) -> Result { let call = self.contract.function("latestFork".into()).map_err(Self::as_string)?; @@ -322,7 +321,7 @@ impl Operations { Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = try!(r.to_uint().ok_or("Invalid type returned")); util::U256::from(r.as_ref()).as_u64() as u32 })) } - /// Auto-generated from: `{"constant":true,"inputs":[{"name":"_client","type":"bytes32"},{"name":"_track","type":"uint8"}],"name":"latestInTrack","outputs":[{"name":"","type":"bytes32"}],"type":"function"}` + /// Auto-generated from: `{"constant":true,"inputs":[{"name":"_client","type":"bytes32"},{"name":"_track","type":"uint8"}],"name":"latestInTrack","outputs":[{"name":"","type":"bytes32"}],"payable":false,"type":"function"}` #[allow(dead_code)] pub fn latest_in_track(&self, _client: &str, _track: u8) -> Result { let call = self.contract.function("latestInTrack".into()).map_err(Self::as_string)?; @@ -334,19 +333,19 @@ impl Operations { Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = try!(r.to_fixed_bytes().ok_or("Invalid type returned")); util::H256::from_slice(r.as_ref()) })) } - /// Auto-generated from: `{"constant":true,"inputs":[{"name":"","type":"bytes32"}],"name":"clients","outputs":[{"name":"owner","type":"address"},{"name":"required","type":"bool"}],"type":"function"}` + /// Auto-generated from: `{"constant":true,"inputs":[{"name":"_client","type":"bytes32"},{"name":"_release","type":"bytes32"},{"name":"_platform","type":"bytes32"}],"name":"checksum","outputs":[{"name":"","type":"bytes32"}],"payable":false,"type":"function"}` #[allow(dead_code)] - pub fn clients(&self, _1: &util::H256) -> Result<(util::Address, bool), String> { - let call = self.contract.function("clients".into()).map_err(Self::as_string)?; + pub fn checksum(&self, _client: &str, _release: &util::H256, _platform: &str) -> Result { + let call = self.contract.function("checksum".into()).map_err(Self::as_string)?; let data = call.encode_call( - vec![ethabi::Token::FixedBytes(_1.as_ref().to_owned())] + vec![ethabi::Token::FixedBytes(_client.as_bytes().to_owned()), ethabi::Token::FixedBytes(_release.as_ref().to_owned()), ethabi::Token::FixedBytes(_platform.as_bytes().to_owned())] ).map_err(Self::as_string)?; let output = call.decode_output((self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; let mut result = output.into_iter().rev().collect::>(); - Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = try!(r.to_address().ok_or("Invalid type returned")); util::Address::from(r) }, { let r = result.pop().ok_or("Invalid return arity")?; let r = try!(r.to_bool().ok_or("Invalid type returned")); r })) + Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = try!(r.to_fixed_bytes().ok_or("Invalid type returned")); util::H256::from_slice(r.as_ref()) })) } - /// Auto-generated from: `{"constant":true,"inputs":[],"name":"proposedFork","outputs":[{"name":"","type":"uint32"}],"type":"function"}` + /// Auto-generated from: `{"constant":true,"inputs":[],"name":"proposedFork","outputs":[{"name":"","type":"uint32"}],"payable":false,"type":"function"}` #[allow(dead_code)] pub fn proposed_fork(&self) -> Result { let call = self.contract.function("proposedFork".into()).map_err(Self::as_string)?; diff --git a/ethcore/src/client/test_client.rs b/ethcore/src/client/test_client.rs index 84ed25b37..f7f572914 100644 --- a/ethcore/src/client/test_client.rs +++ b/ethcore/src/client/test_client.rs @@ -24,8 +24,8 @@ use devtools::*; use transaction::{Transaction, LocalizedTransaction, SignedTransaction, Action}; use blockchain::TreeRoute; use client::{ - BlockChainClient, MiningBlockChainClient, BlockChainInfo, BlockStatus, BlockID, - TransactionID, UncleID, TraceId, TraceFilter, LastHashes, CallAnalytics, BlockImportError, + BlockChainClient, MiningBlockChainClient, BlockChainInfo, BlockStatus, BlockId, + TransactionId, UncleId, TraceId, TraceFilter, LastHashes, CallAnalytics, BlockImportError, }; use db::{NUM_COLUMNS, COL_STATE}; use header::{Header as BlockHeader, BlockNumber}; @@ -72,7 +72,7 @@ pub struct TestBlockChainClient { /// Execution result. pub execution_result: RwLock>>, /// Transaction receipts. - pub receipts: RwLock>, + pub receipts: RwLock>, /// Logs pub logs: RwLock>, /// Block queue size. @@ -157,7 +157,7 @@ impl TestBlockChainClient { } /// Set the transaction receipt result - pub fn set_transaction_receipt(&self, id: TransactionID, receipt: LocalizedReceipt) { + pub fn set_transaction_receipt(&self, id: TransactionId, receipt: LocalizedReceipt) { self.receipts.write().insert(id, receipt); } @@ -255,8 +255,8 @@ impl TestBlockChainClient { /// Make a bad block by setting invalid extra data. pub fn corrupt_block(&mut self, n: BlockNumber) { - let hash = self.block_hash(BlockID::Number(n)).unwrap(); - let mut header: BlockHeader = decode(&self.block_header(BlockID::Number(n)).unwrap()); + let hash = self.block_hash(BlockId::Number(n)).unwrap(); + let mut header: BlockHeader = decode(&self.block_header(BlockId::Number(n)).unwrap()); header.set_extra_data(b"This extra data is way too long to be considered valid".to_vec()); let mut rlp = RlpStream::new_list(3); rlp.append(&header); @@ -267,8 +267,8 @@ impl TestBlockChainClient { /// Make a bad block by setting invalid parent hash. pub fn corrupt_block_parent(&mut self, n: BlockNumber) { - let hash = self.block_hash(BlockID::Number(n)).unwrap(); - let mut header: BlockHeader = decode(&self.block_header(BlockID::Number(n)).unwrap()); + let hash = self.block_hash(BlockId::Number(n)).unwrap(); + let mut header: BlockHeader = decode(&self.block_header(BlockId::Number(n)).unwrap()); header.set_parent_hash(H256::from(42)); let mut rlp = RlpStream::new_list(3); rlp.append(&header); @@ -284,12 +284,12 @@ impl TestBlockChainClient { blocks_read[&index].clone() } - fn block_hash(&self, id: BlockID) -> Option { + fn block_hash(&self, id: BlockId) -> Option { match id { - BlockID::Hash(hash) => Some(hash), - BlockID::Number(n) => self.numbers.read().get(&(n as usize)).cloned(), - BlockID::Earliest => self.numbers.read().get(&0).cloned(), - BlockID::Latest | BlockID::Pending => self.numbers.read().get(&(self.numbers.read().len() - 1)).cloned() + BlockId::Hash(hash) => Some(hash), + BlockId::Number(n) => self.numbers.read().get(&(n as usize)).cloned(), + BlockId::Earliest => self.numbers.read().get(&0).cloned(), + BlockId::Latest | BlockId::Pending => self.numbers.read().get(&(self.numbers.read().len() - 1)).cloned() } } @@ -362,42 +362,42 @@ impl MiningBlockChainClient for TestBlockChainClient { } impl BlockChainClient for TestBlockChainClient { - fn call(&self, _t: &SignedTransaction, _block: BlockID, _analytics: CallAnalytics) -> Result { + fn call(&self, _t: &SignedTransaction, _block: BlockId, _analytics: CallAnalytics) -> Result { self.execution_result.read().clone().unwrap() } - fn replay(&self, _id: TransactionID, _analytics: CallAnalytics) -> Result { + fn replay(&self, _id: TransactionId, _analytics: CallAnalytics) -> Result { self.execution_result.read().clone().unwrap() } - fn block_total_difficulty(&self, _id: BlockID) -> Option { + fn block_total_difficulty(&self, _id: BlockId) -> Option { Some(U256::zero()) } - fn block_hash(&self, id: BlockID) -> Option { + fn block_hash(&self, id: BlockId) -> Option { Self::block_hash(self, id) } - fn nonce(&self, address: &Address, id: BlockID) -> Option { + fn nonce(&self, address: &Address, id: BlockId) -> Option { match id { - BlockID::Latest => Some(self.nonces.read().get(address).cloned().unwrap_or(self.spec.params.account_start_nonce)), + BlockId::Latest => Some(self.nonces.read().get(address).cloned().unwrap_or(self.spec.params.account_start_nonce)), _ => None, } } fn latest_nonce(&self, address: &Address) -> U256 { - self.nonce(address, BlockID::Latest).unwrap() + self.nonce(address, BlockId::Latest).unwrap() } - fn code(&self, address: &Address, id: BlockID) -> Option> { + fn code(&self, address: &Address, id: BlockId) -> Option> { match id { - BlockID::Latest => Some(self.code.read().get(address).cloned()), + BlockId::Latest => Some(self.code.read().get(address).cloned()), _ => None, } } - fn balance(&self, address: &Address, id: BlockID) -> Option { - if let BlockID::Latest = id { + fn balance(&self, address: &Address, id: BlockId) -> Option { + if let BlockId::Latest = id { Some(self.balances.read().get(address).cloned().unwrap_or_else(U256::zero)) } else { None @@ -405,38 +405,38 @@ impl BlockChainClient for TestBlockChainClient { } fn latest_balance(&self, address: &Address) -> U256 { - self.balance(address, BlockID::Latest).unwrap() + self.balance(address, BlockId::Latest).unwrap() } - fn storage_at(&self, address: &Address, position: &H256, id: BlockID) -> Option { - if let BlockID::Latest = id { + fn storage_at(&self, address: &Address, position: &H256, id: BlockId) -> Option { + if let BlockId::Latest = id { Some(self.storage.read().get(&(address.clone(), position.clone())).cloned().unwrap_or_else(H256::new)) } else { None } } - fn list_accounts(&self, _id: BlockID) -> Option> { + fn list_accounts(&self, _id: BlockId) -> Option> { None } - fn transaction(&self, _id: TransactionID) -> Option { + fn transaction(&self, _id: TransactionId) -> Option { None // Simple default. } - fn uncle(&self, _id: UncleID) -> Option { + fn uncle(&self, _id: UncleId) -> Option { None // Simple default. } - fn uncle_extra_info(&self, _id: UncleID) -> Option> { + fn uncle_extra_info(&self, _id: UncleId) -> Option> { None } - fn transaction_receipt(&self, id: TransactionID) -> Option { + fn transaction_receipt(&self, id: TransactionId) -> Option { self.receipts.read().get(&id).cloned() } - fn blocks_with_bloom(&self, _bloom: &H2048, _from_block: BlockID, _to_block: BlockID) -> Option> { + fn blocks_with_bloom(&self, _bloom: &H2048, _from_block: BlockId, _to_block: BlockId) -> Option> { unimplemented!(); } @@ -454,14 +454,14 @@ impl BlockChainClient for TestBlockChainClient { } fn best_block_header(&self) -> Bytes { - self.block_header(BlockID::Hash(self.chain_info().best_block_hash)).expect("Best block always have header.") + self.block_header(BlockId::Hash(self.chain_info().best_block_hash)).expect("Best block always have header.") } - fn block_header(&self, id: BlockID) -> Option { + fn block_header(&self, id: BlockId) -> Option { self.block_hash(id).and_then(|hash| self.blocks.read().get(&hash).map(|r| Rlp::new(r).at(0).as_raw().to_vec())) } - fn block_body(&self, id: BlockID) -> Option { + fn block_body(&self, id: BlockId) -> Option { self.block_hash(id).and_then(|hash| self.blocks.read().get(&hash).map(|r| { let mut stream = RlpStream::new_list(2); stream.append_raw(Rlp::new(r).at(1).as_raw(), 1); @@ -470,21 +470,21 @@ impl BlockChainClient for TestBlockChainClient { })) } - fn block(&self, id: BlockID) -> Option { + fn block(&self, id: BlockId) -> Option { self.block_hash(id).and_then(|hash| self.blocks.read().get(&hash).cloned()) } - fn block_extra_info(&self, id: BlockID) -> Option> { + fn block_extra_info(&self, id: BlockId) -> Option> { self.block(id) .map(|block| BlockView::new(&block).header()) .map(|header| self.spec.engine.extra_info(&header)) } - fn block_status(&self, id: BlockID) -> BlockStatus { + fn block_status(&self, id: BlockId) -> BlockStatus { match id { - BlockID::Number(number) if (number as usize) < self.blocks.read().len() => BlockStatus::InChain, - BlockID::Hash(ref hash) if self.blocks.read().get(hash).is_some() => BlockStatus::InChain, + BlockId::Number(number) if (number as usize) < self.blocks.read().len() => BlockStatus::InChain, + BlockId::Hash(ref hash) if self.blocks.read().get(hash).is_some() => BlockStatus::InChain, _ => BlockStatus::Unknown } } @@ -637,11 +637,11 @@ impl BlockChainClient for TestBlockChainClient { unimplemented!(); } - fn transaction_traces(&self, _trace: TransactionID) -> Option> { + fn transaction_traces(&self, _trace: TransactionId) -> Option> { unimplemented!(); } - fn block_traces(&self, _trace: BlockID) -> Option> { + fn block_traces(&self, _trace: BlockId) -> Option> { unimplemented!(); } diff --git a/ethcore/src/client/traits.rs b/ethcore/src/client/traits.rs index 67092e986..a6605c434 100644 --- a/ethcore/src/client/traits.rs +++ b/ethcore/src/client/traits.rs @@ -49,81 +49,81 @@ pub trait BlockChainClient : Sync + Send { fn keep_alive(&self) {} /// Get raw block header data by block id. - fn block_header(&self, id: BlockID) -> Option; + fn block_header(&self, id: BlockId) -> Option; /// Get raw block body data by block id. /// Block body is an RLP list of two items: uncles and transactions. - fn block_body(&self, id: BlockID) -> Option; + fn block_body(&self, id: BlockId) -> Option; /// Get raw block data by block header hash. - fn block(&self, id: BlockID) -> Option; + fn block(&self, id: BlockId) -> Option; /// Get block status by block header hash. - fn block_status(&self, id: BlockID) -> BlockStatus; + fn block_status(&self, id: BlockId) -> BlockStatus; /// Get block total difficulty. - fn block_total_difficulty(&self, id: BlockID) -> Option; + fn block_total_difficulty(&self, id: BlockId) -> Option; /// Attempt to get address nonce at given block. - /// May not fail on BlockID::Latest. - fn nonce(&self, address: &Address, id: BlockID) -> Option; + /// May not fail on BlockId::Latest. + fn nonce(&self, address: &Address, id: BlockId) -> Option; /// Get address nonce at the latest block's state. fn latest_nonce(&self, address: &Address) -> U256 { - self.nonce(address, BlockID::Latest) - .expect("nonce will return Some when given BlockID::Latest. nonce was given BlockID::Latest. \ + self.nonce(address, BlockId::Latest) + .expect("nonce will return Some when given BlockId::Latest. nonce was given BlockId::Latest. \ Therefore nonce has returned Some; qed") } /// Get block hash. - fn block_hash(&self, id: BlockID) -> Option; + fn block_hash(&self, id: BlockId) -> Option; /// Get address code at given block's state. - fn code(&self, address: &Address, id: BlockID) -> Option>; + fn code(&self, address: &Address, id: BlockId) -> Option>; /// Get address code at the latest block's state. fn latest_code(&self, address: &Address) -> Option { - self.code(address, BlockID::Latest) - .expect("code will return Some if given BlockID::Latest; qed") + self.code(address, BlockId::Latest) + .expect("code will return Some if given BlockId::Latest; qed") } /// Get address balance at the given block's state. /// - /// May not return None if given BlockID::Latest. + /// May not return None if given BlockId::Latest. /// Returns None if and only if the block's root hash has been pruned from the DB. - fn balance(&self, address: &Address, id: BlockID) -> Option; + fn balance(&self, address: &Address, id: BlockId) -> Option; /// Get address balance at the latest block's state. fn latest_balance(&self, address: &Address) -> U256 { - self.balance(address, BlockID::Latest) - .expect("balance will return Some if given BlockID::Latest. balance was given BlockID::Latest \ + self.balance(address, BlockId::Latest) + .expect("balance will return Some if given BlockId::Latest. balance was given BlockId::Latest \ Therefore balance has returned Some; qed") } /// Get value of the storage at given position at the given block's state. /// - /// May not return None if given BlockID::Latest. + /// May not return None if given BlockId::Latest. /// Returns None if and only if the block's root hash has been pruned from the DB. - fn storage_at(&self, address: &Address, position: &H256, id: BlockID) -> Option; + fn storage_at(&self, address: &Address, position: &H256, id: BlockId) -> Option; /// Get value of the storage at given position at the latest block's state. fn latest_storage_at(&self, address: &Address, position: &H256) -> H256 { - self.storage_at(address, position, BlockID::Latest) - .expect("storage_at will return Some if given BlockID::Latest. storage_at was given BlockID::Latest. \ + self.storage_at(address, position, BlockId::Latest) + .expect("storage_at will return Some if given BlockId::Latest. storage_at was given BlockId::Latest. \ Therefore storage_at has returned Some; qed") } /// Get a list of all accounts in the block `id`, if fat DB is in operation, otherwise `None`. - fn list_accounts(&self, id: BlockID) -> Option>; + fn list_accounts(&self, id: BlockId) -> Option>; /// Get transaction with given hash. - fn transaction(&self, id: TransactionID) -> Option; + fn transaction(&self, id: TransactionId) -> Option; /// Get uncle with given id. - fn uncle(&self, id: UncleID) -> Option; + fn uncle(&self, id: UncleId) -> Option; /// Get transaction receipt with given hash. - fn transaction_receipt(&self, id: TransactionID) -> Option; + fn transaction_receipt(&self, id: TransactionId) -> Option; /// Get a tree route between `from` and `to`. /// See `BlockChain::tree_route`. @@ -160,16 +160,16 @@ pub trait BlockChainClient : Sync + Send { fn best_block_header(&self) -> Bytes; /// Returns numbers of blocks containing given bloom. - fn blocks_with_bloom(&self, bloom: &H2048, from_block: BlockID, to_block: BlockID) -> Option>; + fn blocks_with_bloom(&self, bloom: &H2048, from_block: BlockId, to_block: BlockId) -> Option>; /// Returns logs matching given filter. fn logs(&self, filter: Filter) -> Vec; /// Makes a non-persistent transaction call. - fn call(&self, t: &SignedTransaction, block: BlockID, analytics: CallAnalytics) -> Result; + fn call(&self, t: &SignedTransaction, block: BlockId, analytics: CallAnalytics) -> Result; /// Replays a given transaction for inspection. - fn replay(&self, t: TransactionID, analytics: CallAnalytics) -> Result; + fn replay(&self, t: TransactionId, analytics: CallAnalytics) -> Result; /// Returns traces matching given filter. fn filter_traces(&self, filter: TraceFilter) -> Option>; @@ -178,10 +178,10 @@ pub trait BlockChainClient : Sync + Send { fn trace(&self, trace: TraceId) -> Option; /// Returns traces created by transaction. - fn transaction_traces(&self, trace: TransactionID) -> Option>; + fn transaction_traces(&self, trace: TransactionId) -> Option>; /// Returns traces created by transaction from block. - fn block_traces(&self, trace: BlockID) -> Option>; + fn block_traces(&self, trace: BlockId) -> Option>; /// Get last hashes starting from best block. fn last_hashes(&self) -> LastHashes; @@ -198,7 +198,7 @@ pub trait BlockChainClient : Sync + Send { let mut corpus = Vec::new(); while corpus.is_empty() { for _ in 0..sample_size { - let block_bytes = self.block(BlockID::Hash(h)).expect("h is either the best_block_hash or an ancestor; qed"); + let block_bytes = self.block(BlockId::Hash(h)).expect("h is either the best_block_hash or an ancestor; qed"); let block = BlockView::new(&block_bytes); let header = block.header_view(); if header.number() == 0 { @@ -236,11 +236,11 @@ pub trait BlockChainClient : Sync + Send { /// Set the mode. fn set_mode(&self, mode: Mode); - /// Returns engine-related extra info for `BlockID`. - fn block_extra_info(&self, id: BlockID) -> Option>; + /// Returns engine-related extra info for `BlockId`. + fn block_extra_info(&self, id: BlockId) -> Option>; - /// Returns engine-related extra info for `UncleID`. - fn uncle_extra_info(&self, id: UncleID) -> Option>; + /// Returns engine-related extra info for `UncleId`. + fn uncle_extra_info(&self, id: UncleId) -> Option>; } /// Extended client interface used for mining diff --git a/ethcore/src/client/updater.rs b/ethcore/src/client/updater.rs index 4fb210ca6..211fdeb1f 100644 --- a/ethcore/src/client/updater.rs +++ b/ethcore/src/client/updater.rs @@ -15,45 +15,81 @@ // along with Parity. If not, see . use std::sync::Weak; -use util::misc::code_hash; -use util::{Address, H160}; +use util::misc::{VersionInfo, ReleaseTrack, platform}; +use util::{Address, H160, H256, FixedHash}; use client::operations::Operations; use client::client::Client; +use client::BlockId; -pub struct Updater { - operations: Operations, +pub struct ReleaseInfo { + fork_supported: usize, + latest_known_fork: usize, + + latest: VersionInfo, + latest_fork: usize, + latest_binary: Option, } -fn platform() -> &'static str { - "linux_x64" +pub struct Updater { + client: Weak, + operations: Operations, + + pub this: VersionInfo, + pub release_info: Option, + } impl Updater { pub fn new(client: Weak, operations: Address) -> Self { - Updater { + let mut u = Updater { + client: client.clone(), operations: Operations::new(operations, move |a, d| client.upgrade().ok_or("No client!".into()).and_then(|c| c.call_contract(a, d))), + this: VersionInfo::this(), + release_info: None, + }; + u.release_info = u.get_release_info().ok(); + if u.this.track == ReleaseTrack::Unknown { + u.this.track = ReleaseTrack::Nightly; + } + u + } + + fn get_release_info(&mut self) -> Result { + //601e0fb0fd7e9e1cec18f8872e8713117cab4e84 + if self.this.track == ReleaseTrack::Unknown { + return Err(format!("Current executable ({}) is unreleased.", H160::from(self.this.hash))); } + + let client_id = "parity"; + let latest_known_fork = self.operations.latest_fork()?; + let our_fork = self.operations.release(client_id, &self.this.hash.into())?.0; + let latest_release = self.operations.latest_in_track(client_id, self.this.track.into())?; + let (fork, track, semver, _critical) = self.operations.release(client_id, &latest_release)?; + let maybe_latest_binary = self.operations.checksum(client_id, &latest_release, &platform())?; + Ok(ReleaseInfo { + fork_supported: our_fork as usize, + latest_known_fork: latest_known_fork as usize, + latest: VersionInfo::from_raw(semver, track, latest_release.into()), + latest_fork: fork as usize, + latest_binary: if maybe_latest_binary.is_zero() { None } else { Some(maybe_latest_binary) }, + }) } pub fn tick(&mut self) { - (|| -> Result<(), String> { - let code_hash = H160::from("0x080ec8043f41e25ee8aa4ee6112906ac6d82ea74").into();//code_hash().into(); - let client = "parity"; - - let (fork, track, semver) = self.operations.find_release(client, &code_hash)?; - let track_name = match track { 1 => "stable", 2 => "beta", 3 => "nightly", _ => "unknown" }; - info!(target: "updater", "Current release ({}) is {}.{}.{}-{} and latest fork it supports is at block #{}", H160::from(code_hash), semver >> 16, (semver >> 8) & 0xff, semver & 0xff, track_name, fork); - - let latest_fork = self.operations.latest_fork()?; - info!(target: "updater", "Latest fork is at block #{}", latest_fork); - - let latest = self.operations.latest_in_track(client, track)?; - let (fork, _, semver) = self.operations.find_release(client, &latest)?; - info!(target: "updater", "Latest release in our track is {}.{}.{}-{} ({:?}); supports fork at block #{}", semver >> 16, (semver >> 8) & 0xff, semver & 0xff, track_name, H160::from(latest), fork); - - let exe_hash = self.operations.find_checksum(client, &latest, platform())?; - info!(target: "updater", "Latest release's binary on {} is {}", platform(), exe_hash); - Ok(()) - })().unwrap_or_else(|e| warn!("{}", e)); + self.release_info = self.get_release_info().ok(); + let current_number = self.client.upgrade().map_or(0, |c| c.block_number(BlockId::Latest).unwrap_or(0)); + info!(target: "updater", "Current release is {}", self.this); + if let Some(ref relinfo) = self.release_info { + info!(target: "updater", "Latest release in our track is {} ({} binary is {})", + relinfo.latest, + platform(), + if let Some(ref b) = relinfo.latest_binary { + format!("{}", b) + } else { + "unreleased".into() + } + ); + info!(target: "updater", "Fork: this/current/latest/latest-known: #{}/#{}/#{}/#{}", relinfo.fork_supported, current_number, relinfo.latest_fork, relinfo.latest_known_fork); + } } } diff --git a/ethcore/src/miner/miner.rs b/ethcore/src/miner/miner.rs index 7ad18ebfc..29f28265f 100644 --- a/ethcore/src/miner/miner.rs +++ b/ethcore/src/miner/miner.rs @@ -23,7 +23,7 @@ use account_provider::AccountProvider; use views::{BlockView, HeaderView}; use header::Header; use state::{State, CleanupMode}; -use client::{MiningBlockChainClient, Executive, Executed, EnvInfo, TransactOptions, BlockID, CallAnalytics}; +use client::{MiningBlockChainClient, Executive, Executed, EnvInfo, TransactOptions, BlockId, CallAnalytics}; use client::TransactionImportResult; use executive::contract_address; use block::{ClosedBlock, SealedBlock, IsBlock, Block}; @@ -693,7 +693,7 @@ impl MinerService for Miner { Ok(ret) }, None => { - chain.call(t, BlockID::Latest, analytics) + chain.call(t, BlockId::Latest, analytics) } } } @@ -1073,7 +1073,7 @@ impl MinerService for Miner { fn fetch_transactions(chain: &MiningBlockChainClient, hash: &H256) -> Vec { let block = chain - .block(BlockID::Hash(*hash)) + .block(BlockId::Hash(*hash)) // Client should send message after commit to db and inserting to chain. .expect("Expected in-chain blocks."); let block = BlockView::new(&block); diff --git a/ethcore/src/snapshot/error.rs b/ethcore/src/snapshot/error.rs index d417695f0..cc84d8e48 100644 --- a/ethcore/src/snapshot/error.rs +++ b/ethcore/src/snapshot/error.rs @@ -18,7 +18,7 @@ use std::fmt; -use ids::BlockID; +use ids::BlockId; use util::H256; use util::trie::TrieError; @@ -28,7 +28,7 @@ use rlp::DecoderError; #[derive(Debug)] pub enum Error { /// Invalid starting block for snapshot. - InvalidStartingBlock(BlockID), + InvalidStartingBlock(BlockId), /// Block not found. BlockNotFound(H256), /// Incomplete chain. diff --git a/ethcore/src/snapshot/mod.rs b/ethcore/src/snapshot/mod.rs index 3f63ac208..76695fbf2 100644 --- a/ethcore/src/snapshot/mod.rs +++ b/ethcore/src/snapshot/mod.rs @@ -27,7 +27,7 @@ use account_db::{AccountDB, AccountDBMut}; use blockchain::{BlockChain, BlockProvider}; use engines::Engine; use header::Header; -use ids::BlockID; +use ids::BlockId; use views::BlockView; use util::{Bytes, Hashable, HashDB, DBValue, snappy, U256, Uint}; @@ -129,7 +129,7 @@ pub fn take_snapshot( p: &Progress ) -> Result<(), Error> { let start_header = try!(chain.block_header(&block_at) - .ok_or(Error::InvalidStartingBlock(BlockID::Hash(block_at)))); + .ok_or(Error::InvalidStartingBlock(BlockId::Hash(block_at)))); let state_root = start_header.state_root(); let number = start_header.number(); diff --git a/ethcore/src/snapshot/service.rs b/ethcore/src/snapshot/service.rs index c0d34a6a9..21725bc06 100644 --- a/ethcore/src/snapshot/service.rs +++ b/ethcore/src/snapshot/service.rs @@ -30,7 +30,7 @@ use blockchain::BlockChain; use client::{BlockChainClient, Client}; use engines::Engine; use error::Error; -use ids::BlockID; +use ids::BlockId; use service::ClientIoMessage; use io::IoChannel; @@ -353,7 +353,7 @@ impl Service { let writer = try!(LooseWriter::new(temp_dir.clone())); let guard = Guard::new(temp_dir.clone()); - let res = client.take_snapshot(writer, BlockID::Number(num), &self.progress); + let res = client.take_snapshot(writer, BlockId::Number(num), &self.progress); self.taking_snapshot.store(false, Ordering::SeqCst); if let Err(e) = res { diff --git a/ethcore/src/snapshot/tests/service.rs b/ethcore/src/snapshot/tests/service.rs index e136985c6..efdb12323 100644 --- a/ethcore/src/snapshot/tests/service.rs +++ b/ethcore/src/snapshot/tests/service.rs @@ -19,7 +19,7 @@ use std::sync::Arc; use client::{BlockChainClient, Client}; -use ids::BlockID; +use ids::BlockId; use snapshot::service::{Service, ServiceParams}; use snapshot::{self, ManifestData, SnapshotService}; use spec::Spec; @@ -96,8 +96,8 @@ fn restored_is_equivalent() { assert_eq!(service.status(), ::snapshot::RestorationStatus::Inactive); for x in 0..NUM_BLOCKS { - let block1 = client.block(BlockID::Number(x as u64)).unwrap(); - let block2 = client2.block(BlockID::Number(x as u64)).unwrap(); + let block1 = client.block(BlockId::Number(x as u64)).unwrap(); + let block2 = client2.block(BlockId::Number(x as u64)).unwrap(); assert_eq!(block1, block2); } diff --git a/ethcore/src/snapshot/watcher.rs b/ethcore/src/snapshot/watcher.rs index 43439e437..ab4dde134 100644 --- a/ethcore/src/snapshot/watcher.rs +++ b/ethcore/src/snapshot/watcher.rs @@ -18,7 +18,7 @@ use util::Mutex; use client::{BlockChainClient, Client, ChainNotify}; -use ids::BlockID; +use ids::BlockId; use service::ClientIoMessage; use views::HeaderView; @@ -43,7 +43,7 @@ impl Oracle for StandardOracle where F: Send + Sync + Fn() -> bool { fn to_number(&self, hash: H256) -> Option { - self.client.block_header(BlockID::Hash(hash)).map(|h| HeaderView::new(&h).number()) + self.client.block_header(BlockId::Hash(hash)).map(|h| HeaderView::new(&h).number()) } fn is_major_importing(&self) -> bool { diff --git a/ethcore/src/tests/client.rs b/ethcore/src/tests/client.rs index 99b251d66..b96de22df 100644 --- a/ethcore/src/tests/client.rs +++ b/ethcore/src/tests/client.rs @@ -15,7 +15,7 @@ // along with Parity. If not, see . use io::IoChannel; -use client::{BlockChainClient, MiningBlockChainClient, Client, ClientConfig, BlockID}; +use client::{BlockChainClient, MiningBlockChainClient, Client, ClientConfig, BlockId}; use state::CleanupMode; use ethereum; use block::IsBlock; @@ -99,7 +99,7 @@ fn imports_good_block() { client.flush_queue(); client.import_verified_blocks(); - let block = client.block_header(BlockID::Number(1)).unwrap(); + let block = client.block_header(BlockId::Number(1)).unwrap(); assert!(!block.is_empty()); } @@ -117,7 +117,7 @@ fn query_none_block() { IoChannel::disconnected(), &db_config ).unwrap(); - let non_existant = client.block_header(BlockID::Number(188)); + let non_existant = client.block_header(BlockId::Number(188)); assert!(non_existant.is_none()); } @@ -125,7 +125,7 @@ fn query_none_block() { fn query_bad_block() { let client_result = get_test_client_with_blocks(vec![get_bad_state_dummy_block()]); let client = client_result.reference(); - let bad_block:Option = client.block_header(BlockID::Number(1)); + let bad_block:Option = client.block_header(BlockId::Number(1)); assert!(bad_block.is_none()); } @@ -146,8 +146,8 @@ fn returns_logs() { let client_result = get_test_client_with_blocks(vec![dummy_block.clone()]); let client = client_result.reference(); let logs = client.logs(Filter { - from_block: BlockID::Earliest, - to_block: BlockID::Latest, + from_block: BlockId::Earliest, + to_block: BlockId::Latest, address: None, topics: vec![], limit: None, @@ -161,8 +161,8 @@ fn returns_logs_with_limit() { let client_result = get_test_client_with_blocks(vec![dummy_block.clone()]); let client = client_result.reference(); let logs = client.logs(Filter { - from_block: BlockID::Earliest, - to_block: BlockID::Latest, + from_block: BlockId::Earliest, + to_block: BlockId::Latest, address: None, topics: vec![], limit: Some(2), @@ -176,7 +176,7 @@ fn returns_block_body() { let client_result = get_test_client_with_blocks(vec![dummy_block.clone()]); let client = client_result.reference(); let block = BlockView::new(&dummy_block); - let body = client.block_body(BlockID::Hash(block.header().hash())).unwrap(); + let body = client.block_body(BlockId::Hash(block.header().hash())).unwrap(); let body = Rlp::new(&body); assert_eq!(body.item_count(), 2); assert_eq!(body.at(0).as_raw()[..], block.rlp().at(1).as_raw()[..]); @@ -187,7 +187,7 @@ fn returns_block_body() { fn imports_block_sequence() { let client_result = generate_dummy_client(6); let client = client_result.reference(); - let block = client.block_header(BlockID::Number(5)).unwrap(); + let block = client.block_header(BlockId::Number(5)).unwrap(); assert!(!block.is_empty()); } diff --git a/ethcore/src/tests/rpc.rs b/ethcore/src/tests/rpc.rs index b021e750d..2da94b3d0 100644 --- a/ethcore/src/tests/rpc.rs +++ b/ethcore/src/tests/rpc.rs @@ -19,7 +19,7 @@ use nanoipc; use std::sync::Arc; use std::sync::atomic::{Ordering, AtomicBool}; -use client::{Client, BlockChainClient, ClientConfig, BlockID}; +use client::{Client, BlockChainClient, ClientConfig, BlockId}; use client::remote::RemoteClient; use tests::helpers::*; use devtools::*; @@ -71,7 +71,7 @@ fn can_query_block() { run_test_worker(scope, stop_guard.share(), socket_path); let remote_client = nanoipc::generic_client::>(socket_path).unwrap(); - let non_existant_block = remote_client.block_header(BlockID::Number(999)); + let non_existant_block = remote_client.block_header(BlockId::Number(999)); assert!(non_existant_block.is_none()); }) diff --git a/ethcore/src/types/filter.rs b/ethcore/src/types/filter.rs index e3487e5f6..ecc997f71 100644 --- a/ethcore/src/types/filter.rs +++ b/ethcore/src/types/filter.rs @@ -18,17 +18,17 @@ use util::{Address, H256, Hashable, H2048}; use util::bloom::Bloomable; -use client::BlockID; +use client::BlockId; use log_entry::LogEntry; /// Blockchain Filter. #[derive(Binary, Debug, PartialEq)] pub struct Filter { /// Blockchain will be searched from this block. - pub from_block: BlockID, + pub from_block: BlockId, /// Till this block. - pub to_block: BlockID, + pub to_block: BlockId, /// Search addresses. /// @@ -114,14 +114,14 @@ impl Filter { mod tests { use util::FixedHash; use filter::Filter; - use client::BlockID; + use client::BlockId; use log_entry::LogEntry; #[test] fn test_bloom_possibilities_none() { let none_filter = Filter { - from_block: BlockID::Earliest, - to_block: BlockID::Latest, + from_block: BlockId::Earliest, + to_block: BlockId::Latest, address: None, topics: vec![None, None, None, None], limit: None, @@ -136,8 +136,8 @@ mod tests { #[test] fn test_bloom_possibilities_single_address_and_topic() { let filter = Filter { - from_block: BlockID::Earliest, - to_block: BlockID::Latest, + from_block: BlockId::Earliest, + to_block: BlockId::Latest, address: Some(vec!["b372018f3be9e171df0581136b59d2faf73a7d5d".into()]), topics: vec![ Some(vec!["ff74e91598aed6ae5d2fdcf8b24cd2c7be49a0808112a305069355b7160f23f9".into()]), @@ -155,8 +155,8 @@ mod tests { #[test] fn test_bloom_possibilities_single_address_and_many_topics() { let filter = Filter { - from_block: BlockID::Earliest, - to_block: BlockID::Latest, + from_block: BlockId::Earliest, + to_block: BlockId::Latest, address: Some(vec!["b372018f3be9e171df0581136b59d2faf73a7d5d".into()]), topics: vec![ Some(vec!["ff74e91598aed6ae5d2fdcf8b24cd2c7be49a0808112a305069355b7160f23f9".into()]), @@ -174,8 +174,8 @@ mod tests { #[test] fn test_bloom_possibilites_multiple_addresses_and_topics() { let filter = Filter { - from_block: BlockID::Earliest, - to_block: BlockID::Latest, + from_block: BlockId::Earliest, + to_block: BlockId::Latest, address: Some(vec![ "b372018f3be9e171df0581136b59d2faf73a7d5d".into(), "b372018f3be9e171df0581136b59d2faf73a7d5d".into(), @@ -204,8 +204,8 @@ mod tests { #[test] fn test_filter_matches() { let filter = Filter { - from_block: BlockID::Earliest, - to_block: BlockID::Latest, + from_block: BlockId::Earliest, + to_block: BlockId::Latest, address: Some(vec!["b372018f3be9e171df0581136b59d2faf73a7d5d".into()]), topics: vec![ Some(vec!["ff74e91598aed6ae5d2fdcf8b24cd2c7be49a0808112a305069355b7160f23f9".into()]), diff --git a/ethcore/src/types/ids.rs b/ethcore/src/types/ids.rs index 1fe81f392..2c3c777b4 100644 --- a/ethcore/src/types/ids.rs +++ b/ethcore/src/types/ids.rs @@ -21,7 +21,7 @@ use header::BlockNumber; /// Uniquely identifies block. #[derive(Debug, PartialEq, Copy, Clone, Hash, Eq, Binary)] -pub enum BlockID { +pub enum BlockId { /// Block's sha3. /// Querying by hash is always faster. Hash(H256), @@ -37,28 +37,28 @@ pub enum BlockID { /// Uniquely identifies transaction. #[derive(Debug, PartialEq, Clone, Hash, Eq, Binary)] -pub enum TransactionID { +pub enum TransactionId { /// Transaction's sha3. Hash(H256), /// Block id and transaction index within this block. /// Querying by block position is always faster. - Location(BlockID, usize) + Location(BlockId, usize) } /// Uniquely identifies Trace. #[derive(Binary)] pub struct TraceId { /// Transaction - pub transaction: TransactionID, + pub transaction: TransactionId, /// Trace address within transaction. pub address: Vec, } /// Uniquely identifies Uncle. #[derive(Debug, PartialEq, Eq, Copy, Clone, Binary)] -pub struct UncleID { +pub struct UncleId { /// Block id. - pub block: BlockID, + pub block: BlockId, /// Position in block. pub position: usize } diff --git a/ethcore/src/types/trace_filter.rs b/ethcore/src/types/trace_filter.rs index c17cc9e85..af9d7c3ee 100644 --- a/ethcore/src/types/trace_filter.rs +++ b/ethcore/src/types/trace_filter.rs @@ -18,13 +18,13 @@ use std::ops::Range; use util::{Address}; -use types::ids::BlockID; +use types::ids::BlockId; /// Easy to use trace filter. #[derive(Binary)] pub struct Filter { /// Range of filtering. - pub range: Range, + pub range: Range, /// From address. pub from_address: Vec
, /// To address. diff --git a/ethstore/src/dir/disk.rs b/ethstore/src/dir/disk.rs index 56b2c1ccb..c86123d1a 100644 --- a/ethstore/src/dir/disk.rs +++ b/ethstore/src/dir/disk.rs @@ -20,7 +20,7 @@ use std::collections::HashMap; use time; use ethkey::Address; use {json, SafeAccount, Error}; -use json::UUID; +use json::Uuid; use super::KeyDirectory; const IGNORED_FILES: &'static [&'static str] = &["thumbs.db", "address_book.json"]; @@ -113,7 +113,7 @@ impl KeyDirectory for DiskDirectory { // build file path let filename = account.filename.as_ref().cloned().unwrap_or_else(|| { let timestamp = time::strftime("%Y-%m-%dT%H-%M-%S", &time::now_utc()).expect("Time-format string is valid."); - format!("UTC--{}Z--{}", timestamp, UUID::from(account.id)) + format!("UTC--{}Z--{}", timestamp, Uuid::from(account.id)) }); // update account filename diff --git a/ethstore/src/ethstore.rs b/ethstore/src/ethstore.rs index 4991c4714..3747431fb 100644 --- a/ethstore/src/ethstore.rs +++ b/ethstore/src/ethstore.rs @@ -24,7 +24,7 @@ use dir::KeyDirectory; use account::SafeAccount; use {Error, SecretStore}; use json; -use json::UUID; +use json::Uuid; use parking_lot::RwLock; use presale::PresaleWallet; use import; @@ -154,7 +154,7 @@ impl SecretStore for EthStore { account.public(password) } - fn uuid(&self, address: &Address) -> Result { + fn uuid(&self, address: &Address) -> Result { let account = try!(self.get(address)); Ok(account.id.into()) } diff --git a/ethstore/src/json/error.rs b/ethstore/src/json/error.rs index 5e077cfad..a3ea4d326 100644 --- a/ethstore/src/json/error.rs +++ b/ethstore/src/json/error.rs @@ -21,7 +21,7 @@ pub enum Error { UnsupportedCipher, InvalidCipherParams, UnsupportedKdf, - InvalidUUID, + InvalidUuid, UnsupportedVersion, InvalidCiphertext, InvalidH256, @@ -31,7 +31,7 @@ pub enum Error { impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { - Error::InvalidUUID => write!(f, "Invalid UUID"), + Error::InvalidUuid => write!(f, "Invalid Uuid"), Error::UnsupportedVersion => write!(f, "Unsupported version"), Error::UnsupportedKdf => write!(f, "Unsupported kdf"), Error::InvalidCiphertext => write!(f, "Invalid ciphertext"), diff --git a/ethstore/src/json/id.rs b/ethstore/src/json/id.rs index ff282a9f8..664716d95 100644 --- a/ethstore/src/json/id.rs +++ b/ethstore/src/json/id.rs @@ -23,15 +23,15 @@ use super::Error; /// Universaly unique identifier. #[derive(Debug, PartialEq)] -pub struct UUID([u8; 16]); +pub struct Uuid([u8; 16]); -impl From<[u8; 16]> for UUID { +impl From<[u8; 16]> for Uuid { fn from(uuid: [u8; 16]) -> Self { - UUID(uuid) + Uuid(uuid) } } -impl<'a> Into for &'a UUID { +impl<'a> Into for &'a Uuid { fn into(self) -> String { let d1 = &self.0[0..4]; let d2 = &self.0[4..6]; @@ -42,44 +42,44 @@ impl<'a> Into for &'a UUID { } } -impl Into for UUID { +impl Into for Uuid { fn into(self) -> String { Into::into(&self) } } -impl Into<[u8; 16]> for UUID { +impl Into<[u8; 16]> for Uuid { fn into(self) -> [u8; 16] { self.0 } } -impl fmt::Display for UUID { +impl fmt::Display for Uuid { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - let s: String = (self as &UUID).into(); + let s: String = (self as &Uuid).into(); write!(f, "{}", s) } } fn copy_into(from: &str, into: &mut [u8]) -> Result<(), Error> { - let from = try!(from.from_hex().map_err(|_| Error::InvalidUUID)); + let from = try!(from.from_hex().map_err(|_| Error::InvalidUuid)); if from.len() != into.len() { - return Err(Error::InvalidUUID); + return Err(Error::InvalidUuid); } into.copy_from_slice(&from); Ok(()) } -impl str::FromStr for UUID { +impl str::FromStr for Uuid { type Err = Error; fn from_str(s: &str) -> Result { let parts: Vec<&str> = s.split("-").collect(); if parts.len() != 5 { - return Err(Error::InvalidUUID); + return Err(Error::InvalidUuid); } let mut uuid = [0u8; 16]; @@ -90,17 +90,17 @@ impl str::FromStr for UUID { try!(copy_into(parts[3], &mut uuid[8..10])); try!(copy_into(parts[4], &mut uuid[10..16])); - Ok(UUID(uuid)) + Ok(Uuid(uuid)) } } -impl From<&'static str> for UUID { +impl From<&'static str> for Uuid { fn from(s: &'static str) -> Self { s.parse().expect(&format!("invalid string literal for {}: '{}'", stringify!(Self), s)) } } -impl Serialize for UUID { +impl Serialize for Uuid { fn serialize(&self, serializer: &mut S) -> Result<(), S::Error> where S: Serializer { let s: String = self.into(); @@ -108,17 +108,17 @@ impl Serialize for UUID { } } -impl Deserialize for UUID { +impl Deserialize for Uuid { fn deserialize(deserializer: &mut D) -> Result where D: Deserializer { - deserializer.deserialize(UUIDVisitor) + deserializer.deserialize(UuidVisitor) } } -struct UUIDVisitor; +struct UuidVisitor; -impl Visitor for UUIDVisitor { - type Value = UUID; +impl Visitor for UuidVisitor { + type Value = Uuid; fn visit_str(&mut self, value: &str) -> Result where E: SerdeError { value.parse().map_err(SerdeError::custom) @@ -131,18 +131,18 @@ impl Visitor for UUIDVisitor { #[cfg(test)] mod tests { - use super::UUID; + use super::Uuid; #[test] fn uuid_from_str() { - let uuid: UUID = "3198bc9c-6672-5ab3-d995-4942343ae5b6".into(); - assert_eq!(uuid, UUID::from([0x31, 0x98, 0xbc, 0x9c, 0x66, 0x72, 0x5a, 0xb3, 0xd9, 0x95, 0x49, 0x42, 0x34, 0x3a, 0xe5, 0xb6])); + let uuid: Uuid = "3198bc9c-6672-5ab3-d995-4942343ae5b6".into(); + assert_eq!(uuid, Uuid::from([0x31, 0x98, 0xbc, 0x9c, 0x66, 0x72, 0x5a, 0xb3, 0xd9, 0x95, 0x49, 0x42, 0x34, 0x3a, 0xe5, 0xb6])); } #[test] fn uuid_from_and_to_str() { let from = "3198bc9c-6672-5ab3-d995-4942343ae5b6"; - let uuid: UUID = from.into(); + let uuid: Uuid = from.into(); let to: String = uuid.into(); assert_eq!(from, &to); } diff --git a/ethstore/src/json/key_file.rs b/ethstore/src/json/key_file.rs index 6e37c7c89..5bc5a4e1c 100644 --- a/ethstore/src/json/key_file.rs +++ b/ethstore/src/json/key_file.rs @@ -18,11 +18,11 @@ use std::io::{Read, Write}; use serde::{Deserialize, Deserializer, Error}; use serde::de::{Visitor, MapVisitor}; use serde_json; -use super::{UUID, Version, Crypto, H160}; +use super::{Uuid, Version, Crypto, H160}; #[derive(Debug, PartialEq, Serialize)] pub struct KeyFile { - pub id: UUID, + pub id: Uuid, pub version: Version, pub crypto: Crypto, pub address: H160, @@ -153,7 +153,7 @@ impl KeyFile { mod tests { use std::str::FromStr; use serde_json; - use json::{KeyFile, UUID, Version, Crypto, Cipher, Aes128Ctr, Kdf, Scrypt}; + use json::{KeyFile, Uuid, Version, Crypto, Cipher, Aes128Ctr, Kdf, Scrypt}; #[test] fn basic_keyfile() { @@ -183,7 +183,7 @@ mod tests { }"#; let expected = KeyFile { - id: UUID::from_str("8777d9f6-7860-4b9b-88b7-0b57ee6b3a73").unwrap(), + id: Uuid::from_str("8777d9f6-7860-4b9b-88b7-0b57ee6b3a73").unwrap(), version: Version::V3, address: "6edddfc6349aff20bc6467ccf276c5b52487f7a8".into(), crypto: Crypto { diff --git a/ethstore/src/json/mod.rs.in b/ethstore/src/json/mod.rs.in index 133d9821e..8ad48b994 100644 --- a/ethstore/src/json/mod.rs.in +++ b/ethstore/src/json/mod.rs.in @@ -14,7 +14,7 @@ pub use self::cipher::{Cipher, CipherSer, CipherSerParams, Aes128Ctr}; pub use self::crypto::{Crypto, CipherText}; pub use self::error::Error; pub use self::hash::{H128, H160, H256}; -pub use self::id::UUID; +pub use self::id::Uuid; pub use self::kdf::{Kdf, KdfSer, Prf, Pbkdf2, Scrypt, KdfSerParams}; pub use self::key_file::KeyFile; pub use self::presale::{PresaleWallet, Encseed}; diff --git a/ethstore/src/secret_store.rs b/ethstore/src/secret_store.rs index 06f38922b..bf0a4ec44 100644 --- a/ethstore/src/secret_store.rs +++ b/ethstore/src/secret_store.rs @@ -16,7 +16,7 @@ use ethkey::{Address, Message, Signature, Secret, Public}; use Error; -use json::UUID; +use json::Uuid; pub trait SecretStore: Send + Sync { fn insert_account(&self, secret: Secret, password: &str) -> Result; @@ -30,7 +30,7 @@ pub trait SecretStore: Send + Sync { fn public(&self, account: &Address, password: &str) -> Result; fn accounts(&self) -> Result, Error>; - fn uuid(&self, account: &Address) -> Result; + fn uuid(&self, account: &Address) -> Result; fn name(&self, account: &Address) -> Result; fn meta(&self, account: &Address) -> Result; diff --git a/parity/blockchain.rs b/parity/blockchain.rs index 0baeb1354..7696d1b38 100644 --- a/parity/blockchain.rs +++ b/parity/blockchain.rs @@ -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 { 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."); } diff --git a/parity/cli/usage.txt b/parity/cli/usage.txt index 89603d311..807de7977 100644 --- a/parity/cli/usage.txt +++ b/parity/cli/usage.txt @@ -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}). diff --git a/parity/configuration.rs b/parity/configuration.rs index 61063aa18..e3f11685e 100644 --- a/parity/configuration.rs +++ b/parity/configuration.rs @@ -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, }))); } diff --git a/parity/dapps.rs b/parity/dapps.rs index 16ae4dd98..ec6fd8846 100644 --- a/parity/dapps.rs +++ b/parity/dapps.rs @@ -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 diff --git a/parity/helpers.rs b/parity/helpers.rs index ab0dafddd..fe5303ec8 100644 --- a/parity/helpers.rs +++ b/parity/helpers.rs @@ -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 { } } -pub fn to_block_id(s: &str) -> Result { +pub fn to_block_id(s: &str) -> Result { 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()) ); } diff --git a/parity/informant.rs b/parity/informant.rs index d3e3c8a20..1caeb1b7c 100644 --- a/parity/informant.rs +++ b/parity/informant.rs @@ -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(); diff --git a/parity/snapshot.rs b/parity/snapshot.rs index d8323084d..804047596 100644 --- a/parity/snapshot.rs +++ b/parity/snapshot.rs @@ -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, 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 diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index 5f1449e07..36cdc3f99 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -33,7 +33,7 @@ use util::sha3::*; use util::{FromHex, Mutex}; use rlp::{self, UntrustedRlp, View}; use ethcore::account_provider::AccountProvider; -use ethcore::client::{MiningBlockChainClient, BlockID, TransactionID, UncleID}; +use ethcore::client::{MiningBlockChainClient, BlockId, TransactionId, UncleId}; use ethcore::header::{Header as BlockHeader, BlockNumber as EthBlockNumber}; use ethcore::block::IsBlock; use ethcore::views::*; @@ -120,7 +120,7 @@ impl EthClient where } } - fn block(&self, id: BlockID, include_txs: bool) -> Result, Error> { + fn block(&self, id: BlockId, include_txs: bool) -> Result, Error> { let client = take_weak!(self.client); match (client.block(id.clone()), client.block_total_difficulty(id)) { (Some(bytes), Some(total_difficulty)) => { @@ -160,20 +160,20 @@ impl EthClient where } } - fn transaction(&self, id: TransactionID) -> Result, Error> { + fn transaction(&self, id: TransactionId) -> Result, Error> { match take_weak!(self.client).transaction(id) { Some(t) => Ok(Some(Transaction::from(t))), None => Ok(None), } } - fn uncle(&self, id: UncleID) -> Result, Error> { + fn uncle(&self, id: UncleId) -> Result, Error> { let client = take_weak!(self.client); let uncle: BlockHeader = match client.uncle(id) { Some(rlp) => rlp::decode(&rlp), None => { return Ok(None); } }; - let parent_difficulty = match client.block_total_difficulty(BlockID::Hash(uncle.parent_hash().clone())) { + let parent_difficulty = match client.block_total_difficulty(BlockId::Hash(uncle.parent_hash().clone())) { Some(difficulty) => difficulty, None => { return Ok(None); } }; @@ -394,7 +394,7 @@ impl Eth for EthClient where fn block_transaction_count_by_hash(&self, hash: RpcH256) -> Result, Error> { try!(self.active()); Ok( - take_weak!(self.client).block(BlockID::Hash(hash.into())) + take_weak!(self.client).block(BlockId::Hash(hash.into())) .map(|bytes| BlockView::new(&bytes).transactions_count().into()) ) } @@ -417,7 +417,7 @@ impl Eth for EthClient where try!(self.active()); Ok( - take_weak!(self.client).block(BlockID::Hash(hash.into())) + take_weak!(self.client).block(BlockId::Hash(hash.into())) .map(|bytes| BlockView::new(&bytes).uncles_count().into()) ) } @@ -450,7 +450,7 @@ impl Eth for EthClient where fn block_by_hash(&self, hash: RpcH256, include_txs: bool) -> Result, Error> { try!(self.active()); - self.block(BlockID::Hash(hash.into()), include_txs) + self.block(BlockId::Hash(hash.into()), include_txs) } fn block_by_number(&self, num: BlockNumber, include_txs: bool) -> Result, Error> { @@ -464,19 +464,19 @@ impl Eth for EthClient where let hash: H256 = hash.into(); let miner = take_weak!(self.miner); let client = take_weak!(self.client); - Ok(try!(self.transaction(TransactionID::Hash(hash))).or_else(|| miner.transaction(client.chain_info().best_block_number, &hash).map(Into::into))) + Ok(try!(self.transaction(TransactionId::Hash(hash))).or_else(|| miner.transaction(client.chain_info().best_block_number, &hash).map(Into::into))) } fn transaction_by_block_hash_and_index(&self, hash: RpcH256, index: Index) -> Result, Error> { try!(self.active()); - self.transaction(TransactionID::Location(BlockID::Hash(hash.into()), index.value())) + self.transaction(TransactionId::Location(BlockId::Hash(hash.into()), index.value())) } fn transaction_by_block_number_and_index(&self, num: BlockNumber, index: Index) -> Result, Error> { try!(self.active()); - self.transaction(TransactionID::Location(num.into(), index.value())) + self.transaction(TransactionId::Location(num.into(), index.value())) } fn transaction_receipt(&self, hash: RpcH256) -> Result, Error> { @@ -489,7 +489,7 @@ impl Eth for EthClient where (Some(receipt), true) => Ok(Some(receipt.into())), _ => { let client = take_weak!(self.client); - let receipt = client.transaction_receipt(TransactionID::Hash(hash)); + let receipt = client.transaction_receipt(TransactionId::Hash(hash)); Ok(receipt.map(Into::into)) } } @@ -498,13 +498,13 @@ impl Eth for EthClient where fn uncle_by_block_hash_and_index(&self, hash: RpcH256, index: Index) -> Result, Error> { try!(self.active()); - self.uncle(UncleID { block: BlockID::Hash(hash.into()), position: index.value() }) + self.uncle(UncleId { block: BlockId::Hash(hash.into()), position: index.value() }) } fn uncle_by_block_number_and_index(&self, num: BlockNumber, index: Index) -> Result, Error> { try!(self.active()); - self.uncle(UncleID { block: num.into(), position: index.value() }) + self.uncle(UncleId { block: num.into(), position: index.value() }) } fn compilers(&self) -> Result, Error> { diff --git a/rpc/src/v1/impls/eth_filter.rs b/rpc/src/v1/impls/eth_filter.rs index dd1c937ac..695ff5251 100644 --- a/rpc/src/v1/impls/eth_filter.rs +++ b/rpc/src/v1/impls/eth_filter.rs @@ -21,7 +21,7 @@ use std::collections::HashSet; use jsonrpc_core::*; use ethcore::miner::MinerService; use ethcore::filter::Filter as EthcoreFilter; -use ethcore::client::{BlockChainClient, BlockID}; +use ethcore::client::{BlockChainClient, BlockId}; use util::Mutex; use v1::traits::EthFilter; use v1::types::{BlockNumber, Index, Filter, FilterChanges, Log, H256 as RpcH256, U256 as RpcU256}; @@ -98,7 +98,7 @@ impl EthFilter for EthFilterClient // + 1, cause we want to return hashes including current block hash. let current_number = client.chain_info().best_block_number + 1; let hashes = (*block_number..current_number).into_iter() - .map(BlockID::Number) + .map(BlockId::Number) .filter_map(|id| client.block_hash(id)) .map(Into::into) .collect::>(); @@ -140,10 +140,10 @@ impl EthFilter for EthFilterClient // build appropriate filter let mut filter: EthcoreFilter = filter.clone().into(); - filter.from_block = BlockID::Number(*block_number); - filter.to_block = BlockID::Latest; + filter.from_block = BlockId::Number(*block_number); + filter.to_block = BlockId::Latest; - // retrieve logs in range from_block..min(BlockID::Latest..to_block) + // retrieve logs in range from_block..min(BlockId::Latest..to_block) let mut logs = client.logs(filter.clone()) .into_iter() .map(From::from) diff --git a/rpc/src/v1/impls/parity.rs b/rpc/src/v1/impls/parity.rs index 1fdcbdef8..4a274627a 100644 --- a/rpc/src/v1/impls/parity.rs +++ b/rpc/src/v1/impls/parity.rs @@ -28,7 +28,7 @@ use ethstore::random_phrase; use ethsync::{SyncProvider, ManageNetwork}; use ethcore::miner::MinerService; use ethcore::client::{MiningBlockChainClient}; -use ethcore::ids::BlockID; +use ethcore::ids::BlockId; use ethcore::mode::Mode; use ethcore::account_provider::AccountProvider; @@ -238,7 +238,7 @@ impl Parity for ParityClient where try!(self.active()); Ok(take_weak!(self.client) - .list_accounts(BlockID::Latest) + .list_accounts(BlockId::Latest) .map(|a| a.into_iter().map(Into::into).collect())) } diff --git a/rpc/src/v1/impls/traces.rs b/rpc/src/v1/impls/traces.rs index e85d961a1..0b287ce29 100644 --- a/rpc/src/v1/impls/traces.rs +++ b/rpc/src/v1/impls/traces.rs @@ -19,7 +19,7 @@ use std::sync::{Weak, Arc}; use jsonrpc_core::*; use rlp::{UntrustedRlp, View}; -use ethcore::client::{BlockChainClient, CallAnalytics, TransactionID, TraceId}; +use ethcore::client::{BlockChainClient, CallAnalytics, TransactionId, TraceId}; use ethcore::miner::MinerService; use ethcore::transaction::{Transaction as EthTransaction, SignedTransaction, Action}; use v1::traits::Traces; @@ -100,7 +100,7 @@ impl Traces for TracesClient where C: BlockChainClient + 'static, M: from_params::<(H256,)>(params) .and_then(|(transaction_hash,)| { let client = take_weak!(self.client); - let traces = client.transaction_traces(TransactionID::Hash(transaction_hash.into())); + let traces = client.transaction_traces(TransactionId::Hash(transaction_hash.into())); let traces = traces.map_or_else(Vec::new, |traces| traces.into_iter().map(LocalizedTrace::from).collect()); Ok(to_value(&traces)) }) @@ -112,7 +112,7 @@ impl Traces for TracesClient where C: BlockChainClient + 'static, M: .and_then(|(transaction_hash, address)| { let client = take_weak!(self.client); let id = TraceId { - transaction: TransactionID::Hash(transaction_hash.into()), + transaction: TransactionId::Hash(transaction_hash.into()), address: address.into_iter().map(|i| i.value()).collect() }; let trace = client.trace(id); @@ -153,7 +153,7 @@ impl Traces for TracesClient where C: BlockChainClient + 'static, M: try!(self.active()); from_params::<(H256, _)>(params) .and_then(|(transaction_hash, flags)| { - match take_weak!(self.client).replay(TransactionID::Hash(transaction_hash.into()), to_call_analytics(flags)) { + match take_weak!(self.client).replay(TransactionId::Hash(transaction_hash.into()), to_call_analytics(flags)) { Ok(e) => Ok(to_value(&TraceResults::from(e))), _ => Ok(Value::Null), } diff --git a/rpc/src/v1/tests/eth.rs b/rpc/src/v1/tests/eth.rs index 2f5131f32..9a298dde4 100644 --- a/rpc/src/v1/tests/eth.rs +++ b/rpc/src/v1/tests/eth.rs @@ -19,7 +19,7 @@ use std::sync::Arc; use std::time::Duration; use ethcore::client::{BlockChainClient, Client, ClientConfig}; -use ethcore::ids::BlockID; +use ethcore::ids::BlockId; use ethcore::spec::{Genesis, Spec}; use ethcore::block::Block; use ethcore::views::BlockView; @@ -424,7 +424,7 @@ fn verify_transaction_counts(name: String, chain: BlockChain) { assert_eq!(tester.handler.handle_request_sync(&req), Some(res)); // uncles can share block numbers, so skip them. - if tester.client.block_hash(BlockID::Number(number)) == Some(hash) { + if tester.client.block_hash(BlockId::Number(number)) == Some(hash) { let (req, res) = by_number(number, count, &mut id); assert_eq!(tester.handler.handle_request_sync(&req), Some(res)); } diff --git a/rpc/src/v1/tests/mocked/eth.rs b/rpc/src/v1/tests/mocked/eth.rs index 861bb5234..f0b6eeac1 100644 --- a/rpc/src/v1/tests/mocked/eth.rs +++ b/rpc/src/v1/tests/mocked/eth.rs @@ -24,7 +24,7 @@ use rlp; use util::{Uint, U256, Address, H256, FixedHash, Mutex}; use ethcore::account_provider::AccountProvider; -use ethcore::client::{TestBlockChainClient, EachBlockWith, Executed, TransactionID}; +use ethcore::client::{TestBlockChainClient, EachBlockWith, Executed, TransactionId}; use ethcore::log_entry::{LocalizedLogEntry, LogEntry}; use ethcore::receipt::LocalizedReceipt; use ethcore::transaction::{Transaction, Action}; @@ -950,7 +950,7 @@ fn rpc_eth_transaction_receipt() { let hash = H256::from_str("b903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238").unwrap(); let tester = EthTester::default(); - tester.client.set_transaction_receipt(TransactionID::Hash(hash), receipt); + tester.client.set_transaction_receipt(TransactionId::Hash(hash), receipt); let request = r#"{ "jsonrpc": "2.0", diff --git a/rpc/src/v1/types/block_number.rs b/rpc/src/v1/types/block_number.rs index 01625f8ed..0a2b2f305 100644 --- a/rpc/src/v1/types/block_number.rs +++ b/rpc/src/v1/types/block_number.rs @@ -16,7 +16,7 @@ use serde::{Deserialize, Deserializer, Error}; use serde::de::Visitor; -use ethcore::client::BlockID; +use ethcore::client::BlockId; /// Represents rpc api block number param. #[derive(Debug, PartialEq, Clone)] @@ -64,20 +64,20 @@ impl Visitor for BlockNumberVisitor { } } -impl Into for BlockNumber { - fn into(self) -> BlockID { +impl Into for BlockNumber { + fn into(self) -> BlockId { match self { - BlockNumber::Num(n) => BlockID::Number(n), - BlockNumber::Earliest => BlockID::Earliest, - BlockNumber::Latest => BlockID::Latest, - BlockNumber::Pending => BlockID::Pending, + BlockNumber::Num(n) => BlockId::Number(n), + BlockNumber::Earliest => BlockId::Earliest, + BlockNumber::Latest => BlockId::Latest, + BlockNumber::Pending => BlockId::Pending, } } } #[cfg(test)] mod tests { - use ethcore::client::BlockID; + use ethcore::client::BlockId; use super::*; use serde_json; @@ -90,10 +90,10 @@ mod tests { #[test] fn block_number_into() { - assert_eq!(BlockID::Number(100), BlockNumber::Num(100).into()); - assert_eq!(BlockID::Earliest, BlockNumber::Earliest.into()); - assert_eq!(BlockID::Latest, BlockNumber::Latest.into()); - assert_eq!(BlockID::Pending, BlockNumber::Pending.into()); + assert_eq!(BlockId::Number(100), BlockNumber::Num(100).into()); + assert_eq!(BlockId::Earliest, BlockNumber::Earliest.into()); + assert_eq!(BlockId::Latest, BlockNumber::Latest.into()); + assert_eq!(BlockId::Pending, BlockNumber::Pending.into()); } } diff --git a/rpc/src/v1/types/filter.rs b/rpc/src/v1/types/filter.rs index fc163c54b..bc07254e2 100644 --- a/rpc/src/v1/types/filter.rs +++ b/rpc/src/v1/types/filter.rs @@ -18,7 +18,7 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer, Error}; use serde_json::value; use jsonrpc_core::Value; use ethcore::filter::Filter as EthFilter; -use ethcore::client::BlockID; +use ethcore::client::BlockId; use v1::types::{BlockNumber, H160, H256, Log}; /// Variadic value @@ -73,8 +73,8 @@ pub struct Filter { impl Into for Filter { fn into(self) -> EthFilter { EthFilter { - from_block: self.from_block.map_or_else(|| BlockID::Latest, Into::into), - to_block: self.to_block.map_or_else(|| BlockID::Latest, Into::into), + from_block: self.from_block.map_or_else(|| BlockId::Latest, Into::into), + to_block: self.to_block.map_or_else(|| BlockId::Latest, Into::into), address: self.address.and_then(|address| match address { VariadicValue::Null => None, VariadicValue::Single(a) => Some(vec![a.into()]), @@ -128,7 +128,7 @@ mod tests { use super::*; use v1::types::BlockNumber; use ethcore::filter::Filter as EthFilter; - use ethcore::client::BlockID; + use ethcore::client::BlockId; #[test] fn topic_deserialization() { @@ -173,8 +173,8 @@ mod tests { let eth_filter: EthFilter = filter.into(); assert_eq!(eth_filter, EthFilter { - from_block: BlockID::Earliest, - to_block: BlockID::Latest, + from_block: BlockId::Earliest, + to_block: BlockId::Latest, address: Some(vec![]), topics: vec![ None, diff --git a/rpc/src/v1/types/trace_filter.rs b/rpc/src/v1/types/trace_filter.rs index 21e50e175..83ec6b06e 100644 --- a/rpc/src/v1/types/trace_filter.rs +++ b/rpc/src/v1/types/trace_filter.rs @@ -16,7 +16,7 @@ //! Trace filter deserialization. -use ethcore::client::BlockID; +use ethcore::client::BlockId; use ethcore::client; use v1::types::{BlockNumber, H160}; @@ -39,8 +39,8 @@ pub struct TraceFilter { impl Into for TraceFilter { fn into(self) -> client::TraceFilter { - let start = self.from_block.map_or(BlockID::Latest, Into::into); - let end = self.to_block.map_or(BlockID::Latest, Into::into); + let start = self.from_block.map_or(BlockId::Latest, Into::into); + let end = self.to_block.map_or(BlockId::Latest, Into::into); client::TraceFilter { range: start..end, from_address: self.from_address.map_or_else(Vec::new, |x| x.into_iter().map(Into::into).collect()), diff --git a/sync/src/block_sync.rs b/sync/src/block_sync.rs index ff5411140..0a5d8550b 100644 --- a/sync/src/block_sync.rs +++ b/sync/src/block_sync.rs @@ -22,7 +22,7 @@ use util::*; use rlp::*; use ethcore::views::{BlockView}; use ethcore::header::{BlockNumber, Header as BlockHeader}; -use ethcore::client::{BlockStatus, BlockID, BlockImportError}; +use ethcore::client::{BlockStatus, BlockId, BlockImportError}; use ethcore::block::Block; use ethcore::error::{ImportError, BlockError}; use sync_io::SyncIo; @@ -225,7 +225,7 @@ impl BlockDownloader { trace!(target: "sync", "Error decoding block header RLP: {:?}", e); BlockDownloaderImportError::Invalid })); - match io.chain().block_status(BlockID::Hash(hash.clone())) { + match io.chain().block_status(BlockId::Hash(hash.clone())) { BlockStatus::InChain | BlockStatus::Queued => { match self.state { State::Blocks => trace!(target: "sync", "Header already in chain {} ({})", number, hash), @@ -347,7 +347,7 @@ impl BlockDownloader { debug!(target: "sync", "Could not revert to previous ancient block, last: {} ({})", self.last_imported_block, self.last_imported_hash); self.reset(); } else { - match io.chain().block_hash(BlockID::Number(self.last_imported_block - 1)) { + match io.chain().block_hash(BlockId::Number(self.last_imported_block - 1)) { Some(h) => { self.last_imported_block -= 1; self.last_imported_hash = h; diff --git a/sync/src/blocks.rs b/sync/src/blocks.rs index bf0c4b244..bcb9973dc 100644 --- a/sync/src/blocks.rs +++ b/sync/src/blocks.rs @@ -475,7 +475,7 @@ impl BlockCollection { #[cfg(test)] mod test { use super::BlockCollection; - use ethcore::client::{TestBlockChainClient, EachBlockWith, BlockID, BlockChainClient}; + use ethcore::client::{TestBlockChainClient, EachBlockWith, BlockId, BlockChainClient}; use ethcore::views::HeaderView; use ethcore::header::BlockNumber; use util::*; @@ -497,7 +497,7 @@ mod test { assert!(is_empty(&bc)); let client = TestBlockChainClient::new(); client.add_blocks(100, EachBlockWith::Nothing); - let hashes = (0 .. 100).map(|i| (&client as &BlockChainClient).block_hash(BlockID::Number(i)).unwrap()).collect(); + let hashes = (0 .. 100).map(|i| (&client as &BlockChainClient).block_hash(BlockId::Number(i)).unwrap()).collect(); bc.reset_to(hashes); assert!(!is_empty(&bc)); bc.clear(); @@ -511,7 +511,7 @@ mod test { let client = TestBlockChainClient::new(); let nblocks = 200; client.add_blocks(nblocks, EachBlockWith::Nothing); - let blocks: Vec<_> = (0 .. nblocks).map(|i| (&client as &BlockChainClient).block(BlockID::Number(i as BlockNumber)).unwrap()).collect(); + let blocks: Vec<_> = (0 .. nblocks).map(|i| (&client as &BlockChainClient).block(BlockId::Number(i as BlockNumber)).unwrap()).collect(); let headers: Vec<_> = blocks.iter().map(|b| Rlp::new(b).at(0).as_raw().to_vec()).collect(); let hashes: Vec<_> = headers.iter().map(|h| HeaderView::new(h).sha3()).collect(); let heads: Vec<_> = hashes.iter().enumerate().filter_map(|(i, h)| if i % 20 == 0 { Some(h.clone()) } else { None }).collect(); @@ -564,7 +564,7 @@ mod test { let client = TestBlockChainClient::new(); let nblocks = 200; client.add_blocks(nblocks, EachBlockWith::Nothing); - let blocks: Vec<_> = (0 .. nblocks).map(|i| (&client as &BlockChainClient).block(BlockID::Number(i as BlockNumber)).unwrap()).collect(); + let blocks: Vec<_> = (0 .. nblocks).map(|i| (&client as &BlockChainClient).block(BlockId::Number(i as BlockNumber)).unwrap()).collect(); let headers: Vec<_> = blocks.iter().map(|b| Rlp::new(b).at(0).as_raw().to_vec()).collect(); let hashes: Vec<_> = headers.iter().map(|h| HeaderView::new(h).sha3()).collect(); let heads: Vec<_> = hashes.iter().enumerate().filter_map(|(i, h)| if i % 20 == 0 { Some(h.clone()) } else { None }).collect(); @@ -586,7 +586,7 @@ mod test { let client = TestBlockChainClient::new(); let nblocks = 200; client.add_blocks(nblocks, EachBlockWith::Nothing); - let blocks: Vec<_> = (0 .. nblocks).map(|i| (&client as &BlockChainClient).block(BlockID::Number(i as BlockNumber)).unwrap()).collect(); + let blocks: Vec<_> = (0 .. nblocks).map(|i| (&client as &BlockChainClient).block(BlockId::Number(i as BlockNumber)).unwrap()).collect(); let headers: Vec<_> = blocks.iter().map(|b| Rlp::new(b).at(0).as_raw().to_vec()).collect(); let hashes: Vec<_> = headers.iter().map(|h| HeaderView::new(h).sha3()).collect(); let heads: Vec<_> = hashes.iter().enumerate().filter_map(|(i, h)| if i % 20 == 0 { Some(h.clone()) } else { None }).collect(); diff --git a/sync/src/chain.rs b/sync/src/chain.rs index d98b142cb..fd3e82767 100644 --- a/sync/src/chain.rs +++ b/sync/src/chain.rs @@ -94,7 +94,7 @@ use rlp::*; use network::*; use ethcore::views::{HeaderView}; use ethcore::header::{BlockNumber, Header as BlockHeader}; -use ethcore::client::{BlockChainClient, BlockStatus, BlockID, BlockChainInfo, BlockImportError}; +use ethcore::client::{BlockChainClient, BlockStatus, BlockId, BlockChainInfo, BlockImportError}; use ethcore::error::*; use ethcore::snapshot::{ManifestData, RestorationStatus}; use sync_io::SyncIo; @@ -929,7 +929,7 @@ impl ChainSync { io.disable_peer(peer_id); continue; } - match io.chain().block_status(BlockID::Hash(hash.clone())) { + match io.chain().block_status(BlockId::Hash(hash.clone())) { BlockStatus::InChain => { trace!(target: "sync", "New block hash already in chain {:?}", hash); }, @@ -1150,7 +1150,7 @@ impl ChainSync { return; } - let have_latest = io.chain().block_status(BlockID::Hash(peer_latest)) != BlockStatus::Unknown; + let have_latest = io.chain().block_status(BlockId::Hash(peer_latest)) != BlockStatus::Unknown; if !have_latest && (higher_difficulty || force || self.state == SyncState::NewBlocks) { // check if got new blocks to download trace!(target: "sync", "Syncing with {}, force={}, td={:?}, our td={}, state={:?}", peer_id, force, peer_difficulty, syncing_difficulty, self.state); @@ -1442,11 +1442,11 @@ impl ChainSync { // id is a hash let hash: H256 = try!(r.val_at(0)); trace!(target: "sync", "{} -> GetBlockHeaders (hash: {}, max: {}, skip: {}, reverse:{})", peer_id, hash, max_headers, skip, reverse); - match io.chain().block_header(BlockID::Hash(hash)) { + match io.chain().block_header(BlockId::Hash(hash)) { Some(hdr) => { let number = From::from(HeaderView::new(&hdr).number()); debug_assert_eq!(HeaderView::new(&hdr).sha3(), hash); - if max_headers == 1 || io.chain().block_hash(BlockID::Number(number)) != Some(hash) { + if max_headers == 1 || io.chain().block_hash(BlockId::Number(number)) != Some(hash) { // Non canonical header or single header requested // TODO: handle single-step reverse hashchains of non-canon hashes trace!(target:"sync", "Returning single header: {:?}", hash); @@ -1479,7 +1479,7 @@ impl ChainSync { trace!(target: "sync", "{}: Returning cached fork header", peer_id); data.extend_from_slice(hdr); count += 1; - } else if let Some(mut hdr) = io.chain().block_header(BlockID::Number(number)) { + } else if let Some(mut hdr) = io.chain().block_header(BlockId::Number(number)) { data.append(&mut hdr); count += 1; } else { @@ -1513,7 +1513,7 @@ impl ChainSync { let mut added = 0usize; let mut data = Bytes::new(); for i in 0..count { - if let Some(mut hdr) = io.chain().block_body(BlockID::Hash(try!(r.val_at::(i)))) { + if let Some(mut hdr) = io.chain().block_body(BlockId::Hash(try!(r.val_at::(i)))) { data.append(&mut hdr); added += 1; } @@ -1770,7 +1770,7 @@ impl ChainSync { let mut rlp_stream = RlpStream::new_list(blocks.len()); for block_hash in blocks { let mut hash_rlp = RlpStream::new_list(2); - let number = HeaderView::new(&chain.block_header(BlockID::Hash(block_hash.clone())) + let number = HeaderView::new(&chain.block_header(BlockId::Hash(block_hash.clone())) .expect("chain.tree_route and chain.find_uncles only return hahses of blocks that are in the blockchain. qed.")).number(); hash_rlp.append(&block_hash); hash_rlp.append(&number); @@ -1787,7 +1787,7 @@ impl ChainSync { /// creates latest block rlp for the given client fn create_latest_block_rlp(chain: &BlockChainClient) -> Bytes { let mut rlp_stream = RlpStream::new_list(2); - rlp_stream.append_raw(&chain.block(BlockID::Hash(chain.chain_info().best_block_hash)).expect("Best block always exists"), 1); + rlp_stream.append_raw(&chain.block(BlockId::Hash(chain.chain_info().best_block_hash)).expect("Best block always exists"), 1); rlp_stream.append(&chain.chain_info().total_difficulty); rlp_stream.out() } @@ -1795,8 +1795,8 @@ impl ChainSync { /// creates latest block rlp for the given client fn create_new_block_rlp(chain: &BlockChainClient, hash: &H256) -> Bytes { let mut rlp_stream = RlpStream::new_list(2); - rlp_stream.append_raw(&chain.block(BlockID::Hash(hash.clone())).expect("Block has just been sealed; qed"), 1); - rlp_stream.append(&chain.block_total_difficulty(BlockID::Hash(hash.clone())).expect("Block has just been sealed; qed.")); + rlp_stream.append_raw(&chain.block(BlockId::Hash(hash.clone())).expect("Block has just been sealed; qed"), 1); + rlp_stream.append(&chain.block_total_difficulty(BlockId::Hash(hash.clone())).expect("Block has just been sealed; qed.")); rlp_stream.out() } @@ -1804,7 +1804,7 @@ impl ChainSync { fn get_lagging_peers(&mut self, chain_info: &BlockChainInfo, io: &SyncIo) -> Vec { let latest_hash = chain_info.best_block_hash; self.peers.iter_mut().filter_map(|(&id, ref mut peer_info)| - match io.chain().block_status(BlockID::Hash(peer_info.latest_hash.clone())) { + match io.chain().block_status(BlockId::Hash(peer_info.latest_hash.clone())) { BlockStatus::InChain => { if peer_info.latest_hash != latest_hash { Some(id) @@ -1855,7 +1855,7 @@ impl ChainSync { fn propagate_new_hashes(&mut self, chain_info: &BlockChainInfo, io: &mut SyncIo, peers: &[PeerId]) -> usize { trace!(target: "sync", "Sending NewHashes to {:?}", peers); let mut sent = 0; - let last_parent = HeaderView::new(&io.chain().block_header(BlockID::Hash(chain_info.best_block_hash.clone())) + let last_parent = HeaderView::new(&io.chain().block_header(BlockId::Hash(chain_info.best_block_hash.clone())) .expect("Best block always exists")).parent_hash(); for peer_id in peers { sent += match ChainSync::create_new_hashes_rlp(io.chain(), &last_parent, &chain_info.best_block_hash) { @@ -2113,7 +2113,7 @@ mod tests { let mut client = TestBlockChainClient::new(); client.add_blocks(100, EachBlockWith::Nothing); - let blocks: Vec<_> = (0 .. 100).map(|i| (&client as &BlockChainClient).block(BlockID::Number(i as BlockNumber)).unwrap()).collect(); + let blocks: Vec<_> = (0 .. 100).map(|i| (&client as &BlockChainClient).block(BlockId::Number(i as BlockNumber)).unwrap()).collect(); let headers: Vec<_> = blocks.iter().map(|b| Rlp::new(b).at(0).as_raw().to_vec()).collect(); let hashes: Vec<_> = headers.iter().map(|h| HeaderView::new(h).sha3()).collect(); @@ -2286,7 +2286,7 @@ mod tests { let mut client = TestBlockChainClient::new(); client.add_blocks(100, EachBlockWith::Uncle); let mut queue = VecDeque::new(); - let hash = client.block_hash(BlockID::Number(99)).unwrap(); + let hash = client.block_hash(BlockId::Number(99)).unwrap(); let mut sync = dummy_sync_with_peer(client.block_hash_delta_minus(5), &client); let chain_info = client.chain_info(); let ss = TestSnapshotService::new(); @@ -2544,7 +2544,7 @@ mod tests { // Add some balance to clients and reset nonces for h in &[good_blocks[0], retracted_blocks[0]] { - let block = client.block(BlockID::Hash(*h)).unwrap(); + let block = client.block(BlockId::Hash(*h)).unwrap(); let view = BlockView::new(&block); client.set_balance(view.transactions()[0].sender().unwrap(), U256::from(1_000_000_000)); client.set_nonce(view.transactions()[0].sender().unwrap(), U256::from(0)); @@ -2563,7 +2563,7 @@ mod tests { } // We need to update nonce status (because we say that the block has been imported) for h in &[good_blocks[0]] { - let block = client.block(BlockID::Hash(*h)).unwrap(); + let block = client.block(BlockId::Hash(*h)).unwrap(); let view = BlockView::new(&block); client.set_nonce(view.transactions()[0].sender().unwrap(), U256::from(1)); } diff --git a/sync/src/tests/chain.rs b/sync/src/tests/chain.rs index 5fe34428e..30ae131aa 100644 --- a/sync/src/tests/chain.rs +++ b/sync/src/tests/chain.rs @@ -15,7 +15,7 @@ // along with Parity. If not, see . use util::*; -use ethcore::client::{TestBlockChainClient, BlockChainClient, BlockID, EachBlockWith}; +use ethcore::client::{TestBlockChainClient, BlockChainClient, BlockId, EachBlockWith}; use chain::{SyncState}; use super::helpers::*; use SyncConfig; @@ -27,7 +27,7 @@ fn two_peers() { net.peer_mut(1).chain.add_blocks(1000, EachBlockWith::Uncle); net.peer_mut(2).chain.add_blocks(1000, EachBlockWith::Uncle); net.sync(); - assert!(net.peer(0).chain.block(BlockID::Number(1000)).is_some()); + assert!(net.peer(0).chain.block(BlockId::Number(1000)).is_some()); assert_eq!(*net.peer(0).chain.blocks.read(), *net.peer(1).chain.blocks.read()); } @@ -37,7 +37,7 @@ fn long_chain() { let mut net = TestNet::new(2); net.peer_mut(1).chain.add_blocks(50000, EachBlockWith::Nothing); net.sync(); - assert!(net.peer(0).chain.block(BlockID::Number(50000)).is_some()); + assert!(net.peer(0).chain.block(BlockId::Number(50000)).is_some()); assert_eq!(*net.peer(0).chain.blocks.read(), *net.peer(1).chain.blocks.read()); } @@ -71,7 +71,7 @@ fn empty_blocks() { net.peer_mut(2).chain.add_blocks(5, with); } net.sync(); - assert!(net.peer(0).chain.block(BlockID::Number(1000)).is_some()); + assert!(net.peer(0).chain.block(BlockId::Number(1000)).is_some()); assert_eq!(*net.peer(0).chain.blocks.read(), *net.peer(1).chain.blocks.read()); } @@ -123,13 +123,13 @@ fn net_hard_fork() { let ref_client = TestBlockChainClient::new(); ref_client.add_blocks(50, EachBlockWith::Uncle); { - let mut net = TestNet::new_with_fork(2, Some((50, ref_client.block_hash(BlockID::Number(50)).unwrap()))); + let mut net = TestNet::new_with_fork(2, Some((50, ref_client.block_hash(BlockId::Number(50)).unwrap()))); net.peer_mut(0).chain.add_blocks(100, EachBlockWith::Uncle); net.sync(); assert_eq!(net.peer(1).chain.chain_info().best_block_number, 100); } { - let mut net = TestNet::new_with_fork(2, Some((50, ref_client.block_hash(BlockID::Number(50)).unwrap()))); + let mut net = TestNet::new_with_fork(2, Some((50, ref_client.block_hash(BlockId::Number(50)).unwrap()))); net.peer_mut(0).chain.add_blocks(100, EachBlockWith::Nothing); net.sync(); assert_eq!(net.peer(1).chain.chain_info().best_block_number, 0); diff --git a/util/Cargo.toml b/util/Cargo.toml index cc342eeca..2f8f5c6fb 100644 --- a/util/Cargo.toml +++ b/util/Cargo.toml @@ -37,6 +37,7 @@ tiny-keccak= "1.0" ethcore-bloom-journal = { path = "bloom" } regex = "0.1" lru-cache = "0.1.0" +semver = "0.5" [features] default = [] diff --git a/util/src/lib.rs b/util/src/lib.rs index 2b4ac0fed..e62a47e41 100644 --- a/util/src/lib.rs +++ b/util/src/lib.rs @@ -106,6 +106,7 @@ extern crate tiny_keccak; extern crate rlp; extern crate regex; extern crate lru_cache; +extern crate semver; #[macro_use] extern crate heapsize; diff --git a/util/src/misc.rs b/util/src/misc.rs index d9eab1af0..62231da9a 100644 --- a/util/src/misc.rs +++ b/util/src/misc.rs @@ -17,14 +17,15 @@ //! Diff misc. use common::*; +use semver::{Identifier, Version}; use rlp::{Stream, RlpStream}; use target_info::Target; include!(concat!(env!("OUT_DIR"), "/version.rs")); include!(concat!(env!("OUT_DIR"), "/rustc_version.rs")); -#[derive(PartialEq, Eq, Clone, Copy, Debug)] /// Boolean type for clean/dirty status. +#[derive(PartialEq, Eq, Clone, Copy, Debug)] pub enum Filth { /// Data has not been changed. Clean, @@ -32,9 +33,112 @@ pub enum Filth { Dirty, } -/// Get the (SHA1?) 160-bit hash of this build's code base. -pub fn code_hash() -> H160 { - sha().into() +/// A release's track. +#[derive(PartialEq, Eq, Clone, Copy, Debug)] +pub enum ReleaseTrack { + /// Stable track. + Stable, + /// Beta track. + Beta, + /// Nightly track. + Nightly, + /// No known track. + Unknown, +} + +impl fmt::Display for ReleaseTrack { + fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(f, "{}", match *self { + ReleaseTrack::Stable => "stable", + ReleaseTrack::Beta => "beta", + ReleaseTrack::Nightly => "nightly", + ReleaseTrack::Unknown => "unknown", + }) + } +} + +impl<'a> From<&'a str> for ReleaseTrack { + fn from(s: &'a str) -> Self { + match s { + "stable" => ReleaseTrack::Stable, + "beta" => ReleaseTrack::Beta, + "nightly" => ReleaseTrack::Nightly, + _ => ReleaseTrack::Unknown, + } + } +} + +impl From for ReleaseTrack { + fn from(i: u8) -> Self { + match i { + 1 => ReleaseTrack::Stable, + 2 => ReleaseTrack::Beta, + 3 => ReleaseTrack::Nightly, + _ => ReleaseTrack::Unknown, + } + } +} + +impl Into for ReleaseTrack { + fn into(self) -> u8 { + match self { + ReleaseTrack::Stable => 1, + ReleaseTrack::Beta => 2, + ReleaseTrack::Nightly => 3, + ReleaseTrack::Unknown => 0, + } + } +} + +/// Version information of a particular release. +#[derive(Debug, PartialEq)] +pub struct VersionInfo { + /// The track on which it was released. + pub track: ReleaseTrack, + /// The version. + pub version: Version, + /// The (SHA1?) 160-bit hash of this build's code base. + pub hash: H160, +} + +impl fmt::Display for VersionInfo { + fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(f, "{}-{}", self.version, self.hash) + } +} + +impl VersionInfo { + /// Get information for this (currently running) binary. + pub fn this() -> Self { + VersionInfo { + track: env!["CARGO_PKG_VERSION_PRE"].into(), + version: Version::parse(env!["CARGO_PKG_VERSION"]).expect("Environment variables are known to be valid; qed"), + hash: sha().into(), + } + } + + /// Compose the information from the provided raw fields. + pub fn from_raw(semver: u32, track: u8, hash: H160) -> Self { + let t = track.into(); + VersionInfo { + version: Version { + major: (semver >> 16) as u64, + minor: ((semver >> 8) & 0xff) as u64, + patch: (semver & 0xff) as u64, + build: vec![], + pre: vec![Identifier::AlphaNumeric(format!("{}", t))] + }, + track: t, + hash: hash, + } + } +} + +/// Get the platform identifier. +pub fn platform() -> String { + let env = Target::env(); + let env_dash = if env.is_empty() { "" } else { "-" }; + format!("{}-{}{}{}", Target::arch(), Target::os(), env_dash, env) } /// Get the standard version string for this software. @@ -43,18 +147,16 @@ pub fn version() -> String { let sha3_dash = if sha3.is_empty() { "" } else { "-" }; let commit_date = commit_date().replace("-", ""); let date_dash = if commit_date.is_empty() { "" } else { "-" }; - let env = Target::env(); - let env_dash = if env.is_empty() { "" } else { "-" }; - format!("Parity/v{}-unstable{}{}{}{}/{}-{}{}{}/rustc{}", env!("CARGO_PKG_VERSION"), sha3_dash, sha3, date_dash, commit_date, Target::arch(), Target::os(), env_dash, env, rustc_version()) + format!("Parity/v{}-unstable{}{}{}{}/{}/rustc{}", env!("CARGO_PKG_VERSION"), sha3_dash, sha3, date_dash, commit_date, platform(), rustc_version()) } /// Get the standard version data for this software. pub fn version_data() -> Bytes { let mut s = RlpStream::new_list(4); let v = - (u32::from_str(env!("CARGO_PKG_VERSION_MAJOR")).unwrap() << 16) + - (u32::from_str(env!("CARGO_PKG_VERSION_MINOR")).unwrap() << 8) + - u32::from_str(env!("CARGO_PKG_VERSION_PATCH")).unwrap(); + (u32::from_str(env!("CARGO_PKG_VERSION_MAJOR")).expect("Environment variables are known to be valid; qed") << 16) + + (u32::from_str(env!("CARGO_PKG_VERSION_MINOR")).expect("Environment variables are known to be valid; qed") << 8) + + u32::from_str(env!("CARGO_PKG_VERSION_PATCH")).expect("Environment variables are known to be valid; qed"); s.append(&v); s.append(&"Parity"); s.append(&rustc_version());