Compiling Bloc.
This commit is contained in:
parent
4bbc0943a3
commit
7bad30a1bf
21
src/block.rs
21
src/block.rs
@ -1,6 +1,11 @@
|
|||||||
|
use std::collections::hash_set::*;
|
||||||
|
use util::hash::*;
|
||||||
|
use util::error::*;
|
||||||
use transaction::*;
|
use transaction::*;
|
||||||
use engine::*;
|
use engine::*;
|
||||||
|
use header::*;
|
||||||
use env_info::*;
|
use env_info::*;
|
||||||
|
use state::*;
|
||||||
|
|
||||||
/// A transaction/receipt execution entry.
|
/// A transaction/receipt execution entry.
|
||||||
pub struct Entry {
|
pub struct Entry {
|
||||||
@ -22,36 +27,35 @@ pub struct Block {
|
|||||||
impl Block {
|
impl Block {
|
||||||
fn new(header: Header, state: State) -> Block {
|
fn new(header: Header, state: State) -> Block {
|
||||||
Block {
|
Block {
|
||||||
header: Header:new(),
|
header: Header::new(),
|
||||||
state: state,
|
state: state,
|
||||||
archive: Vec::new(),
|
archive: Vec::new(),
|
||||||
archive_set: HashSet::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 for a object that is_a `Block`.
|
||||||
trait IsBlock {
|
pub trait IsBlock {
|
||||||
/// Get the block associated with this object.
|
/// Get the block associated with this object.
|
||||||
fn block(&self) -> &Block;
|
fn block(&self) -> &Block;
|
||||||
|
|
||||||
/// Get the header associated with this object's 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.
|
/// 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.
|
/// 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 {
|
impl IsBlock for Block {
|
||||||
fn block(&self) -> &Block { self }
|
fn block(&self) -> &Block { self }
|
||||||
fn block_mut(&self) -> &mut Block { self }
|
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
/// Block that is ready for transactions to be added.
|
/// 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
|
/// 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(&self) -> &Block { self.block }
|
||||||
fn block_mut(&self) -> &mut Block { self.block.block }
|
fn block_mut(&self) -> &mut Block { self.block.block }
|
||||||
}
|
}
|
||||||
|
*/
|
@ -7,6 +7,7 @@ use util::semantic_version::*;
|
|||||||
use util::error::*;
|
use util::error::*;
|
||||||
use header::Header;
|
use header::Header;
|
||||||
use transaction::Transaction;
|
use transaction::Transaction;
|
||||||
|
use block::Block;
|
||||||
use spec::Spec;
|
use spec::Spec;
|
||||||
use evm_schedule::EvmSchedule;
|
use evm_schedule::EvmSchedule;
|
||||||
use env_info::EnvInfo;
|
use env_info::EnvInfo;
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
|
use util::error::*;
|
||||||
|
use util::rlp::decode;
|
||||||
use engine::Engine;
|
use engine::Engine;
|
||||||
use spec::Spec;
|
use spec::Spec;
|
||||||
|
use block::*;
|
||||||
use evm_schedule::EvmSchedule;
|
use evm_schedule::EvmSchedule;
|
||||||
use env_info::EnvInfo;
|
use env_info::EnvInfo;
|
||||||
|
|
||||||
@ -23,6 +26,7 @@ impl Engine for Ethash {
|
|||||||
/// Apply the block reward on finalisation of the block.
|
/// Apply the block reward on finalisation of the block.
|
||||||
fn on_close_block(&self, block: &mut Block) -> Result<(), EthcoreError> {
|
fn on_close_block(&self, block: &mut Block) -> Result<(), EthcoreError> {
|
||||||
let a = block.header().author.clone();
|
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(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -106,3 +106,4 @@ pub mod views;
|
|||||||
pub mod blockchain;
|
pub mod blockchain;
|
||||||
pub mod extras;
|
pub mod extras;
|
||||||
pub mod ethash;
|
pub mod ethash;
|
||||||
|
pub mod block;
|
@ -8,6 +8,7 @@ use util::trie::*;
|
|||||||
use util::bytes::*;
|
use util::bytes::*;
|
||||||
use util::rlp::*;
|
use util::rlp::*;
|
||||||
use util::uint::*;
|
use util::uint::*;
|
||||||
|
use util::error::*;
|
||||||
use account::Account;
|
use account::Account;
|
||||||
use transaction::Transaction;
|
use transaction::Transaction;
|
||||||
use receipt::Receipt;
|
use receipt::Receipt;
|
||||||
@ -19,7 +20,7 @@ pub struct ApplyInfo {
|
|||||||
r: Receipt,
|
r: Receipt,
|
||||||
}
|
}
|
||||||
|
|
||||||
type ApplyResult = Result<ApplyInfo, EthcoreError>;
|
pub type ApplyResult = Result<ApplyInfo, EthcoreError>;
|
||||||
|
|
||||||
/// Representation of the entire state of all accounts in the system.
|
/// Representation of the entire state of all accounts in the system.
|
||||||
pub struct State {
|
pub struct State {
|
||||||
|
@ -3,7 +3,7 @@ use util::bytes::*;
|
|||||||
use util::uint::*;
|
use util::uint::*;
|
||||||
use util::rlp::*;
|
use util::rlp::*;
|
||||||
|
|
||||||
struct Receipt {
|
pub struct Receipt {
|
||||||
gas_used: U256,
|
gas_used: U256,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user