From 808e517ff031f6203ac37b20e74813a0679ffa85 Mon Sep 17 00:00:00 2001 From: debris Date: Tue, 2 Feb 2016 23:06:34 +0100 Subject: [PATCH] removing unused functions in progress --- ethcore/Cargo.toml | 2 -- ethcore/src/account.rs | 9 +-------- ethcore/src/env_info.rs | 9 +-------- ethcore/src/executive.rs | 24 ++++++++++++------------ ethcore/src/lib.rs | 1 - ethcore/src/spec.rs | 13 ------------- ethcore/src/state.rs | 8 +------- ethcore/src/transaction.rs | 5 ----- 8 files changed, 15 insertions(+), 56 deletions(-) diff --git a/ethcore/Cargo.toml b/ethcore/Cargo.toml index d9c80f3a3..be7652e17 100644 --- a/ethcore/Cargo.toml +++ b/ethcore/Cargo.toml @@ -10,12 +10,10 @@ authors = ["Ethcore "] log = "0.3" env_logger = "0.3" rustc-serialize = "0.3" -flate2 = "0.2" rocksdb = "0.3" heapsize = "0.2.0" rust-crypto = "0.2.34" time = "0.1" -#interpolate_idents = { git = "https://github.com/SkylerLipthay/interpolate_idents" } ethcore-util = { path = "../util" } evmjit = { path = "../evmjit", optional = true } ethash = { path = "../ethash" } diff --git a/ethcore/src/account.rs b/ethcore/src/account.rs index ab7ad1e53..ec39f8043 100644 --- a/ethcore/src/account.rs +++ b/ethcore/src/account.rs @@ -83,15 +83,8 @@ impl Account { } } - /// Reset this account to the status of a not-yet-initialised contract. - /// NOTE: Account should have `init_code()` called on it later. - pub fn reset_code(&mut self) { - self.code_hash = None; - self.code_cache = vec![]; - } - /// Set this account's code to the given code. - /// NOTE: Account should have been created with `new_contract()` or have `reset_code()` called on it. + /// NOTE: Account should have been created with `new_contract()` pub fn init_code(&mut self, code: Bytes) { assert!(self.code_hash.is_none()); self.code_cache = code; diff --git a/ethcore/src/env_info.rs b/ethcore/src/env_info.rs index 8b037036e..7c0516d2a 100644 --- a/ethcore/src/env_info.rs +++ b/ethcore/src/env_info.rs @@ -24,13 +24,6 @@ pub struct EnvInfo { pub gas_used: U256, } -impl EnvInfo { - /// Create empty env_info initialized with zeros - pub fn new() -> EnvInfo { - EnvInfo::default() - } -} - impl Default for EnvInfo { fn default() -> Self { EnvInfo { @@ -97,4 +90,4 @@ r#" assert_eq!(default_env_info.difficulty, x!(0)); } -} \ No newline at end of file +} diff --git a/ethcore/src/executive.rs b/ethcore/src/executive.rs index 1471bdca3..b67b71306 100644 --- a/ethcore/src/executive.rs +++ b/ethcore/src/executive.rs @@ -399,7 +399,7 @@ mod tests { let mut state_result = get_temp_state(); let mut state = state_result.reference_mut(); state.add_balance(&sender, &U256::from(0x100u64)); - let info = EnvInfo::new(); + let info = EnvInfo::default(); let engine = TestEngine::new(0, factory); let mut substate = Substate::new(); @@ -458,7 +458,7 @@ mod tests { let mut state_result = get_temp_state(); let mut state = state_result.reference_mut(); state.add_balance(&sender, &U256::from(100)); - let info = EnvInfo::new(); + let info = EnvInfo::default(); let engine = TestEngine::new(0, factory); let mut substate = Substate::new(); @@ -512,7 +512,7 @@ mod tests { let mut state_result = get_temp_state(); let mut state = state_result.reference_mut(); state.add_balance(&sender, &U256::from(100)); - let info = EnvInfo::new(); + let info = EnvInfo::default(); let engine = TestEngine::new(0, factory); let mut substate = Substate::new(); @@ -564,7 +564,7 @@ mod tests { let mut state_result = get_temp_state(); let mut state = state_result.reference_mut(); state.add_balance(&sender, &U256::from(100)); - let info = EnvInfo::new(); + let info = EnvInfo::default(); let engine = TestEngine::new(1024, factory); let mut substate = Substate::new(); @@ -624,7 +624,7 @@ mod tests { state.init_code(&address_b, code_b.clone()); state.add_balance(&sender, &U256::from(100_000)); - let info = EnvInfo::new(); + let info = EnvInfo::default(); let engine = TestEngine::new(0, factory); let mut substate = Substate::new(); @@ -668,7 +668,7 @@ mod tests { let mut state_result = get_temp_state(); let mut state = state_result.reference_mut(); state.init_code(&address, code.clone()); - let info = EnvInfo::new(); + let info = EnvInfo::default(); let engine = TestEngine::new(0, factory); let mut substate = Substate::new(); @@ -694,7 +694,7 @@ mod tests { let mut state_result = get_temp_state(); let mut state = state_result.reference_mut(); state.add_balance(&sender, &U256::from(18)); - let mut info = EnvInfo::new(); + let mut info = EnvInfo::default(); info.gas_limit = U256::from(100_000); let engine = TestEngine::new(0, factory); @@ -721,7 +721,7 @@ mod tests { let mut state_result = get_temp_state(); let mut state = state_result.reference_mut(); - let mut info = EnvInfo::new(); + let mut info = EnvInfo::default(); info.gas_limit = U256::from(100_000); let engine = TestEngine::new(0, factory); @@ -746,7 +746,7 @@ mod tests { let mut state_result = get_temp_state(); let mut state = state_result.reference_mut(); state.add_balance(&sender, &U256::from(17)); - let mut info = EnvInfo::new(); + let mut info = EnvInfo::default(); info.gas_limit = U256::from(100_000); let engine = TestEngine::new(0, factory); @@ -772,7 +772,7 @@ mod tests { let mut state_result = get_temp_state(); let mut state = state_result.reference_mut(); state.add_balance(&sender, &U256::from(17)); - let mut info = EnvInfo::new(); + let mut info = EnvInfo::default(); info.gas_used = U256::from(20_000); info.gas_limit = U256::from(100_000); let engine = TestEngine::new(0, factory); @@ -799,7 +799,7 @@ mod tests { let mut state_result = get_temp_state(); let mut state = state_result.reference_mut(); state.add_balance(&sender, &U256::from(100_017)); - let mut info = EnvInfo::new(); + let mut info = EnvInfo::default(); info.gas_limit = U256::from(100_000); let engine = TestEngine::new(0, factory); @@ -833,7 +833,7 @@ mod tests { let mut state_result = get_temp_state(); let mut state = state_result.reference_mut(); state.add_balance(&sender, &U256::from_str("152d02c7e14af6800000").unwrap()); - let info = EnvInfo::new(); + let info = EnvInfo::default(); let engine = TestEngine::new(0, factory); let mut substate = Substate::new(); diff --git a/ethcore/src/lib.rs b/ethcore/src/lib.rs index 66da6c274..3df01d898 100644 --- a/ethcore/src/lib.rs +++ b/ethcore/src/lib.rs @@ -63,7 +63,6 @@ #[macro_use] extern crate ethcore_util as util; #[macro_use] extern crate lazy_static; extern crate rustc_serialize; -extern crate flate2; extern crate rocksdb; extern crate heapsize; extern crate crypto; diff --git a/ethcore/src/spec.rs b/ethcore/src/spec.rs index 72da929ce..7cb251096 100644 --- a/ethcore/src/spec.rs +++ b/ethcore/src/spec.rs @@ -1,23 +1,10 @@ //! Parameters for a block chain. use common::*; -use flate2::read::GzDecoder; use engine::*; use pod_state::*; use null_engine::*; -/// Converts file from base64 gzipped bytes to json -fn gzip64res_to_json(source: &[u8]) -> Json { - // there is probably no need to store genesis in based64 gzip, - // but that's what go does, and it was easy to load it this way - let data = source.from_base64().expect("Genesis block is malformed!"); - let data_ref: &[u8] = &data; - let mut decoder = GzDecoder::new(data_ref).expect("Gzip is invalid"); - let mut s: String = "".to_owned(); - decoder.read_to_string(&mut s).expect("Gzip is invalid"); - Json::from_str(&s).expect("Json is invalid") -} - /// Convert JSON value to equivalent RLP representation. // TODO: handle container types. fn json_to_rlp(json: &Json) -> Bytes { diff --git a/ethcore/src/state.rs b/ethcore/src/state.rs index 58cdf85a2..6456aee77 100644 --- a/ethcore/src/state.rs +++ b/ethcore/src/state.rs @@ -143,7 +143,6 @@ impl State { // let old = self.to_pod(); let e = try!(Executive::new(self, env_info, engine).transact(t)); - //println!("Executed: {:?}", e); // TODO uncomment once to_pod() works correctly. // trace!("Applied transaction. Diff:\n{}\n", StateDiff::diff_pod(&old, &self.to_pod())); @@ -153,16 +152,11 @@ impl State { Ok(receipt) } - /// TODO [debris] Please document me + /// Reverts uncommited changed. pub fn revert(&mut self, backup: State) { self.cache = backup.cache; } - /// Convert into a JSON representation. - pub fn as_json(&self) -> String { - unimplemented!(); - } - /// Commit accounts to SecTrieDBMut. This is similar to cpp-ethereum's dev::eth::commit. /// `accounts` is mutable because we may need to commit the code or storage and record that. #[allow(match_ref_pats)] diff --git a/ethcore/src/transaction.rs b/ethcore/src/transaction.rs index 7f681bcac..73eff953c 100644 --- a/ethcore/src/transaction.rs +++ b/ethcore/src/transaction.rs @@ -169,11 +169,6 @@ impl Transaction { } } - /// Note that some fields have changed. Resets the memoised hash. - pub fn note_dirty(&self) { - *self.hash.borrow_mut() = None; - } - /// 0 is `v` is 27, 1 if 28, and 4 otherwise. pub fn standard_v(&self) -> u8 { match self.v { 27 => 0, 28 => 1, _ => 4 } }