new way of loading PodState

This commit is contained in:
debris
2016-03-17 15:51:40 +01:00
parent 1f03ae54d6
commit c695b83e52
8 changed files with 66 additions and 15 deletions

View File

@@ -19,14 +19,19 @@
use std::collections::BTreeMap;
use uint::Uint;
use bytes::Bytes;
use hash::H256;
/// Blockchain test account deserializer.
#[derive(Debug, PartialEq, Deserialize)]
#[derive(Debug, PartialEq, Deserialize, Clone)]
pub struct Account {
balance: Uint,
code: Bytes,
nonce: Uint,
storage: BTreeMap<Uint, Bytes>,
/// Balance.
pub balance: Uint,
/// Code.
pub code: Bytes,
/// Nonce.
pub nonce: Uint,
/// Storage.
pub storage: BTreeMap<Uint, H256>,
}
#[cfg(test)]
@@ -35,7 +40,7 @@ mod tests {
use blockchain::account::Account;
#[test]
fn header_deserialization() {
fn account_deserialization() {
let s = r#"{
"balance" : "0x09184e72a078",
"code" : "0x600140600155",

View File

@@ -25,15 +25,20 @@ use spec::Genesis;
/// Blockchain deserialization.
#[derive(Debug, PartialEq, Deserialize)]
pub struct BlockChain {
/// Genesis block header.
#[serde(rename="genesisBlockHeader")]
genesis_block: Header,
pub genesis_block: Header,
/// Genesis block rlp.
#[serde(rename="genesisRLP")]
genesis_rlp: Bytes,
blocks: Vec<Block>,
pub genesis_rlp: Bytes,
/// Blocks.
pub blocks: Vec<Block>,
/// Post state.
#[serde(rename="postState")]
post_state: State,
pub post_state: State,
/// Pre state.
#[serde(rename="pre")]
pre_state: State,
pub pre_state: State,
}
impl BlockChain {

View File

@@ -22,8 +22,8 @@ use hash::Address;
use blockchain::account::Account;
/// Blockchain test state deserializer.
#[derive(Debug, PartialEq, Deserialize)]
pub struct State(BTreeMap<Address, Account>);
#[derive(Debug, PartialEq, Deserialize, Clone)]
pub struct State(pub BTreeMap<Address, Account>);
impl Deref for State {
type Target = BTreeMap<Address, Account>;