Compiling Bloc.

This commit is contained in:
Gav Wood 2016-01-08 21:33:41 +01:00
parent 4bbc0943a3
commit 7bad30a1bf
6 changed files with 23 additions and 11 deletions

View File

@ -1,6 +1,11 @@
use std::collections::hash_set::*;
use util::hash::*;
use util::error::*;
use transaction::*;
use engine::*;
use header::*;
use env_info::*;
use state::*;
/// A transaction/receipt execution entry.
pub struct Entry {
@ -22,36 +27,35 @@ pub struct Block {
impl Block {
fn new(header: Header, state: State) -> Block {
Block {
header: Header:new(),
header: Header::new(),
state: state,
archive: Vec::new(),
archive_set: HashSet::new(),
}
}
pub fn state_mut(&mut self) -> &mut State { self.state }
pub fn state_mut(&mut self) -> &mut State { &mut self.state }
}
/// Trait for a object that is_a `Block`.
trait IsBlock {
pub trait IsBlock {
/// Get the block associated with this object.
fn block(&self) -> &Block;
/// Get the header associated with this object's block.
pub fn header(&self) -> &Header { self.block().header }
fn header(&self) -> &Header { &self.block().header }
/// Get the final state associated with this object's block.
pub fn state(&self) -> &State { self.block().state }
fn state(&self) -> &State { &self.block().state }
/// Get all information on transactions in this block.
pub fn archive(&self) -> &Vec<Entry> { self.block().archive }
fn archive(&self) -> &Vec<Entry> { &self.block().archive }
}
impl IsBlock for Block {
fn block(&self) -> &Block { self }
fn block_mut(&self) -> &mut Block { self }
}
/*
/// Block that is ready for transactions to be added.
///
/// It's a bit like a Vec<Transaction>, eccept that whenever a transaction is pushed, we execute it and
@ -144,3 +148,4 @@ impl IsBlock for SealedBlock {
fn block(&self) -> &Block { self.block }
fn block_mut(&self) -> &mut Block { self.block.block }
}
*/

View File

@ -7,6 +7,7 @@ use util::semantic_version::*;
use util::error::*;
use header::Header;
use transaction::Transaction;
use block::Block;
use spec::Spec;
use evm_schedule::EvmSchedule;
use env_info::EnvInfo;

View File

@ -1,5 +1,8 @@
use util::error::*;
use util::rlp::decode;
use engine::Engine;
use spec::Spec;
use block::*;
use evm_schedule::EvmSchedule;
use env_info::EnvInfo;
@ -23,6 +26,7 @@ impl Engine for Ethash {
/// Apply the block reward on finalisation of the block.
fn on_close_block(&self, block: &mut Block) -> Result<(), EthcoreError> {
let a = block.header().author.clone();
block.state_mut().add_balance(a, decode(&self.spec().engine_params.get("block_reward").unwrap()));
block.state_mut().add_balance(&a, &decode(&self.spec().engine_params.get("block_reward").unwrap()));
Ok(())
}
}

View File

@ -106,3 +106,4 @@ pub mod views;
pub mod blockchain;
pub mod extras;
pub mod ethash;
pub mod block;

View File

@ -8,6 +8,7 @@ use util::trie::*;
use util::bytes::*;
use util::rlp::*;
use util::uint::*;
use util::error::*;
use account::Account;
use transaction::Transaction;
use receipt::Receipt;
@ -19,7 +20,7 @@ pub struct ApplyInfo {
r: Receipt,
}
type ApplyResult = Result<ApplyInfo, EthcoreError>;
pub type ApplyResult = Result<ApplyInfo, EthcoreError>;
/// Representation of the entire state of all accounts in the system.
pub struct State {

View File

@ -3,7 +3,7 @@ use util::bytes::*;
use util::uint::*;
use util::rlp::*;
struct Receipt {
pub struct Receipt {
gas_used: U256,
}