executive init
This commit is contained in:
parent
8c6d6950ca
commit
146999cfbf
@ -9,7 +9,7 @@ authors = ["Ethcore <admin@ethcore.io>"]
|
||||
[dependencies]
|
||||
log = "0.3"
|
||||
env_logger = "0.3"
|
||||
ethcore-util = "0.1.0"
|
||||
ethcore-util = { path = "../ethcore-util" }
|
||||
rustc-serialize = "0.3"
|
||||
flate2 = "0.2"
|
||||
rocksdb = "0.2"
|
||||
|
43
src/evm/executive.rs
Normal file
43
src/evm/executive.rs
Normal file
@ -0,0 +1,43 @@
|
||||
use state::*;
|
||||
use env_info::*;
|
||||
use engine::*;
|
||||
use transaction::*;
|
||||
|
||||
pub enum ExecutiveResult {
|
||||
Ok
|
||||
}
|
||||
|
||||
pub struct Executive<'a> {
|
||||
state: &'a mut State,
|
||||
info: &'a EnvInfo,
|
||||
engine: &'a Engine,
|
||||
level: usize
|
||||
}
|
||||
|
||||
impl<'a> Executive<'a> {
|
||||
pub fn new(state: &'a mut State, info: &'a EnvInfo, engine: &'a Engine, level: usize) -> Self {
|
||||
Executive {
|
||||
state: state,
|
||||
info: info,
|
||||
engine: engine,
|
||||
level: level
|
||||
}
|
||||
}
|
||||
|
||||
pub fn exec(&mut self, transaction: &Transaction) -> ExecutiveResult {
|
||||
// TODO: validate that we have enough funds
|
||||
|
||||
match transaction.kind() {
|
||||
TransactionKind::MessageCall => self.call(transaction),
|
||||
TransactionKind::ContractCreation => self.create(transaction)
|
||||
}
|
||||
}
|
||||
|
||||
fn call(&mut self, transaction: &Transaction) -> ExecutiveResult {
|
||||
ExecutiveResult::Ok
|
||||
}
|
||||
|
||||
fn create(&mut self, transaction: &Transaction) -> ExecutiveResult {
|
||||
ExecutiveResult::Ok
|
||||
}
|
||||
}
|
@ -5,6 +5,7 @@ pub mod runtime_data;
|
||||
pub mod evm;
|
||||
pub mod vmfactory;
|
||||
pub mod logentry;
|
||||
pub mod executive;
|
||||
#[cfg(feature = "jit" )]
|
||||
mod jit;
|
||||
|
||||
|
@ -1,27 +1,54 @@
|
||||
use std::marker::PhantomData;
|
||||
use util::hash::*;
|
||||
use util::bytes::*;
|
||||
use util::uint::*;
|
||||
use util::rlp::*;
|
||||
|
||||
#[derive(Eq, PartialEq)]
|
||||
pub enum TransactionKind {
|
||||
ContractCreation,
|
||||
MessageCall
|
||||
}
|
||||
|
||||
/// A set of information describing an externally-originating message call
|
||||
/// or contract creation operation.
|
||||
pub struct Transaction {
|
||||
nonce: U256,
|
||||
gas_price: U256,
|
||||
gas: U256,
|
||||
to: Option<Address>,
|
||||
value: U256,
|
||||
data: Bytes,
|
||||
pub nonce: U256,
|
||||
pub gas_price: U256,
|
||||
pub gas: U256,
|
||||
pub to: Option<Address>,
|
||||
pub value: U256,
|
||||
pub data: Bytes,
|
||||
}
|
||||
|
||||
impl Transaction {
|
||||
pub fn new() -> Self {
|
||||
Transaction {
|
||||
nonce: U256::zero(),
|
||||
gas_price: U256::zero(),
|
||||
gas: U256::zero(),
|
||||
to: None,
|
||||
value: U256::zero(),
|
||||
data: vec![]
|
||||
}
|
||||
}
|
||||
|
||||
/// Is this transaction meant to create a contract?
|
||||
pub fn is_contract_creation(&self) -> bool {
|
||||
self.to.is_none()
|
||||
self.kind() == TransactionKind::ContractCreation
|
||||
}
|
||||
|
||||
/// Is this transaction meant to send a message?
|
||||
pub fn is_message_call(&self) -> bool {
|
||||
!self.is_contract_creation()
|
||||
self.kind() == TransactionKind::MessageCall
|
||||
}
|
||||
|
||||
/// Returns transaction type.
|
||||
pub fn kind(&self) -> TransactionKind {
|
||||
match self.to.is_some() {
|
||||
true => TransactionKind::MessageCall,
|
||||
false => TransactionKind::ContractCreation
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user