Fix chainspec storage field. (#3406)

Add a test.
This commit is contained in:
Gav Wood
2016-11-13 13:58:42 +01:00
committed by GitHub
parent 37f49aac1b
commit 4a92668c56
4 changed files with 33 additions and 8 deletions

View File

@@ -89,7 +89,7 @@ impl From<ethjson::blockchain::Account> for PodAccount {
let key: U256 = key.into();
let value: U256 = value.into();
(H256::from(key), H256::from(value))
}).collect()
}).collect(),
}
}
}
@@ -99,8 +99,12 @@ impl From<ethjson::spec::Account> for PodAccount {
PodAccount {
balance: a.balance.map_or_else(U256::zero, Into::into),
nonce: a.nonce.map_or_else(U256::zero, Into::into),
code: a.code.map(Into::into).or_else(|| Some(Vec::new())),
storage: BTreeMap::new()
code: Some(a.code.map_or_else(Vec::new, Into::into)),
storage: a.storage.map_or_else(BTreeMap::new, |s| s.into_iter().map(|(key, value)| {
let key: U256 = key.into();
let value: U256 = value.into();
(H256::from(key), H256::from(value))
}).collect()),
}
}
}
@@ -112,7 +116,7 @@ impl fmt::Display for PodAccount {
self.nonce,
self.code.as_ref().map_or(0, |c| c.len()),
self.code.as_ref().map_or_else(H256::new, |c| c.sha3()),
self.storage.len()
self.storage.len(),
)
}
}

View File

@@ -162,7 +162,7 @@ impl Spec {
/// Get the configured Network ID.
pub fn network_id(&self) -> usize { self.params.network_id }
/// Get the configured Network ID.
/// Get the configured subprotocol name.
pub fn subprotocol_name(&self) -> String { self.params.subprotocol_name.clone() }
/// Get the configured network fork block.