Suppress warnings along with explanation.

This commit is contained in:
Gav Wood 2016-02-03 13:32:57 +01:00
parent c531150f44
commit 3f03ba40ee
5 changed files with 11 additions and 8 deletions

View File

@ -35,6 +35,7 @@ impl Account {
}
/// General constructor.
#[allow(dead_code)] // Used only in test code for now.
pub fn from_pod(pod: PodAccount) -> Account {
Account {
balance: pod.balance,
@ -110,6 +111,7 @@ impl Account {
pub fn nonce(&self) -> &U256 { &self.nonce }
/// return the code hash associated with this account.
#[allow(dead_code)] // Used only in test code for now.
pub fn code_hash(&self) -> H256 {
self.code_hash.clone().unwrap_or(SHA3_EMPTY)
}
@ -126,6 +128,7 @@ impl Account {
}
/// Provide a byte array which hashes to the `code_hash`. returns the hash as a result.
#[allow(dead_code)] // Used only in test code for now.
pub fn note_code(&mut self, code: Bytes) -> Result<(), H256> {
let h = code.sha3();
match self.code_hash {
@ -159,18 +162,14 @@ impl Account {
}
}
/// return the storage root associated with this account.
pub fn base_root(&self) -> &H256 { &self.storage_root }
/// Determine whether there are any un-`commit()`-ed storage-setting operations.
#[allow(dead_code)]
pub fn storage_is_clean(&self) -> bool { self.storage_overlay.borrow().iter().find(|&(_, &(f, _))| f == Filth::Dirty).is_none() }
/// return the storage root associated with this account or None if it has been altered via the overlay.
#[allow(dead_code)]
pub fn storage_root(&self) -> Option<&H256> { if self.storage_is_clean() {Some(&self.storage_root)} else {None} }
/// return the storage root associated with this account or None if it has been altered via the overlay.
pub fn recent_storage_root(&self) -> &H256 { &self.storage_root }
/// return the storage overlay.
pub fn storage_overlay(&self) -> Ref<HashMap<H256, (Filth, H256)>> { self.storage_overlay.borrow() }

View File

@ -49,8 +49,9 @@ impl AccountDiff {
}
}
/// Determine difference between two optionally existance `Account`s. Returns None
/// Determine difference between two optionally existant `Account`s. Returns None
/// if they are the same.
#[allow(dead_code)] // Used only in test code for now.
pub fn diff_pod(pre: Option<&PodAccount>, post: Option<&PodAccount>) -> Option<AccountDiff> {
match (pre, post) {
(None, Some(x)) => Some(AccountDiff {

View File

@ -2,7 +2,6 @@ use common::*;
use engine::Engine;
use executive::Executive;
use pod_account::*;
use pod_state::PodState;
//use state_diff::*; // TODO: uncomment once to_pod() works correctly.
/// Result type for the execution ("application") of a transaction.
@ -194,6 +193,7 @@ impl State {
}
/// Populate a PodAccount map from this state.
#[allow(dead_code)] // Used only in test code for now.
pub fn to_hashmap_pod(&self) -> HashMap<Address, PodAccount> {
// TODO: handle database rather than just the cache.
self.cache.borrow().iter().fold(HashMap::new(), |mut m, (add, opt)| {
@ -273,6 +273,7 @@ use util::rlp::*;
use util::uint::*;
use account::*;
use tests::helpers::*;
use pod_state::PodState;
#[test]
fn code_from_database() {

View File

@ -9,6 +9,7 @@ pub struct StateDiff (BTreeMap<Address, AccountDiff>);
impl StateDiff {
/// Calculate and return diff between `pre` state and `post` state.
#[allow(dead_code)] // Used only in test code for now.
pub fn diff_pod(pre: &PodState, post: &PodState) -> StateDiff {
StateDiff(pre.get().keys().merge(post.get().keys()).filter_map(|acc| AccountDiff::diff_pod(pre.get().get(acc), post.get().get(acc)).map(|d|(acc.clone(), d))).collect())
}

View File

@ -230,6 +230,7 @@ impl Transaction {
}
/// Do basic validation, checking for valid signature and minimum gas,
#[allow(dead_code)] // Used only in tests. TODO: consider use in block validation.
pub fn validate(self, schedule: &Schedule, require_low: bool) -> Result<Transaction, Error> {
if require_low && !ec::is_low_s(&self.s) {
return Err(Error::Util(UtilError::Crypto(CryptoError::InvalidSignature)));