executive in progress

This commit is contained in:
debris 2016-01-07 21:29:36 +01:00
parent ec720aefa9
commit d27a16c945
4 changed files with 17 additions and 7 deletions

View File

@ -1,3 +1,5 @@
use util::hash::*;
use util::uint::*;
use state::*; use state::*;
use env_info::*; use env_info::*;
use engine::*; use engine::*;
@ -27,9 +29,11 @@ impl<'a> Executive<'a> {
pub fn exec(&mut self, transaction: &Transaction) -> ExecutiveResult { pub fn exec(&mut self, transaction: &Transaction) -> ExecutiveResult {
// TODO: validate that we have enough funds // TODO: validate that we have enough funds
self.state.inc_nonce(&transaction.sender());
match transaction.kind() { match transaction.kind() {
TransactionKind::MessageCall => self.call(transaction), TransactionKind::MessageCall => self.call(transaction),
TransactionKind::ContractCreation => self.create(transaction) TransactionKind::ContractCreation => { unimplemented!(); }// self.create(&self.sender(), )
} }
} }
@ -37,7 +41,7 @@ impl<'a> Executive<'a> {
ExecutiveResult::Ok ExecutiveResult::Ok
} }
fn create(&mut self, transaction: &Transaction) -> ExecutiveResult { fn create(&mut self, address: &Address, endowment: &U256, gas_price: &U256, gas: &U256, init: &[u8], origin: &Address) -> ExecutiveResult {
ExecutiveResult::Ok ExecutiveResult::Ok
} }
} }

View File

@ -27,8 +27,8 @@ impl SubState {
} }
} }
/// This structure represents contract execution environment. /// Externality interface for the Virtual Machine providing access to
/// It should be initalized with `State` and contract address. /// world state.
/// ///
/// ```markdown /// ```markdown
/// extern crate ethcore_util as util; /// extern crate ethcore_util as util;
@ -41,7 +41,7 @@ impl SubState {
/// fn main() { /// fn main() {
/// let address = Address::from_str("0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6").unwrap(); /// let address = Address::from_str("0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6").unwrap();
/// let mut data = RuntimeData::new(); /// let mut data = RuntimeData::new();
/// let mut env = Env::new(EnvInfo::new(), State::new_temp(), address); /// let mut ext = Ext::new(EnvInfo::new(), State::new_temp(), address);
/// } /// }
/// ``` /// ```
pub struct Ext { pub struct Ext {

View File

@ -18,7 +18,7 @@ pub struct Transaction {
pub gas: U256, pub gas: U256,
pub to: Option<Address>, pub to: Option<Address>,
pub value: U256, pub value: U256,
pub data: Bytes, pub data: Bytes
} }
impl Transaction { impl Transaction {
@ -33,6 +33,12 @@ impl Transaction {
} }
} }
/// Returns sender of the transaction.
/// TODO: implement
pub fn sender(&self) -> Address {
Address::new()
}
/// Is this transaction meant to create a contract? /// Is this transaction meant to create a contract?
pub fn is_contract_creation(&self) -> bool { pub fn is_contract_creation(&self) -> bool {
self.kind() == TransactionKind::ContractCreation self.kind() == TransactionKind::ContractCreation