moved ethcores spec to its own module, added genesis

This commit is contained in:
debris
2016-03-17 15:15:10 +01:00
parent 0f889d4222
commit 1f03ae54d6
10 changed files with 174 additions and 4 deletions

View File

@@ -59,6 +59,11 @@ impl BlockChain {
timestamp: self.genesis_block.timestamp,
parent_hash: self.genesis_block.parent_hash.clone(),
gas_limit: self.genesis_block.gas_limit,
transactions_root: Some(self.genesis_block.transactions_root.clone()),
receipts_root: Some(self.genesis_block.receipts_root.clone()),
state_root: Some(self.genesis_block.state_root.clone()),
gas_used: Some(self.genesis_block.gas_used),
extra_data: Some(self.genesis_block.extra_data.clone()),
}
}
}

View File

@@ -53,7 +53,7 @@ pub struct Header {
pub parent_hash: H256,
/// Receipt root.
#[serde(rename="receiptTrie")]
pub receipt_root: H256,
pub receipts_root: H256,
/// State root.
#[serde(rename="stateRoot")]
pub state_root: H256,

View File

@@ -33,7 +33,7 @@ pub struct Genesis {
// new seal // TODO: consider moving it to a separate seal structure
#[serde(rename="sealFields")]
/// Number of seal fields.
pub seal_fields: Option<Uint>,
pub seal_fields: Option<usize>,
#[serde(rename="sealRlp")]
/// Seal rlp.
pub seal_rlp: Option<Bytes>,
@@ -50,6 +50,21 @@ pub struct Genesis {
/// Gas limit.
#[serde(rename="gasLimit")]
pub gas_limit: Uint,
/// Transactions root.
#[serde(rename="transactionsRoot")]
pub transactions_root: Option<H256>,
/// Receipts root.
#[serde(rename="receiptsRoot")]
pub receipts_root: Option<H256>,
/// State root.
#[serde(rename="stateRoot")]
pub state_root: Option<H256>,
/// Gas used.
#[serde(rename="gasUsed")]
pub gas_used: Option<Uint>,
/// Extra data.
#[serde(rename="extraData")]
pub extra_data: Option<Bytes>,
}
#[cfg(test)]

View File

@@ -31,6 +31,12 @@ impl Into<U256> for Uint {
}
}
impl Into<u64> for Uint {
fn into(self) -> u64 {
u64::from(self.0)
}
}
impl Deserialize for Uint {
fn deserialize<D>(deserializer: &mut D) -> Result<Self, D::Error>
where D: Deserializer {