docs
This commit is contained in:
parent
2e7f0e29de
commit
156fcad4e2
@ -311,9 +311,6 @@ pub mod ffi {
|
|||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn env_sha3(begin: *const u8, size: u64, out_hash: *mut JitI256) {
|
pub unsafe extern "C" fn env_sha3(begin: *const u8, size: u64, out_hash: *mut JitI256) {
|
||||||
// TODO: write tests
|
|
||||||
// it may be incorrect due to endianess
|
|
||||||
// if it is, don't use `from_raw_parts`
|
|
||||||
let out_hash = &mut *out_hash;
|
let out_hash = &mut *out_hash;
|
||||||
let input = slice::from_raw_parts(begin, size as usize);
|
let input = slice::from_raw_parts(begin, size as usize);
|
||||||
let outlen = out_hash.words.len() * 8;
|
let outlen = out_hash.words.len() * 8;
|
||||||
|
@ -1,13 +1,32 @@
|
|||||||
|
//! Contract execution environment.
|
||||||
|
|
||||||
use util::hash::*;
|
use util::hash::*;
|
||||||
use util::uint::*;
|
use util::uint::*;
|
||||||
use state::*;
|
use state::*;
|
||||||
|
|
||||||
|
/// This structure represents contract execution environment.
|
||||||
|
/// It should be initalized with `State` and contract address.
|
||||||
|
///
|
||||||
|
/// ```markdown
|
||||||
|
/// extern crate ethcore_util as util;
|
||||||
|
/// extern crate ethcore;
|
||||||
|
/// use util::hash::*;
|
||||||
|
/// use ethcore::state::*;
|
||||||
|
/// use ethcore::evm::*;
|
||||||
|
///
|
||||||
|
/// fn main() {
|
||||||
|
/// let address = Address::from_str("0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6").unwrap();
|
||||||
|
/// let mut data = RuntimeData::new();
|
||||||
|
/// let mut env = Env::new(State::new_temp(), address);
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
pub struct Env {
|
pub struct Env {
|
||||||
state: State,
|
state: State,
|
||||||
address: Address
|
address: Address
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Env {
|
impl Env {
|
||||||
|
/// Creates new evm environment object with backing state.
|
||||||
pub fn new(state: State, address: Address) -> Env {
|
pub fn new(state: State, address: Address) -> Env {
|
||||||
Env {
|
Env {
|
||||||
state: state,
|
state: state,
|
||||||
@ -15,17 +34,19 @@ impl Env {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn sload(&self, index: &H256) -> H256 {
|
/// Returns a value for given key.
|
||||||
self.state.storage_at(&self.address, index)
|
pub fn sload(&self, key: &H256) -> H256 {
|
||||||
|
self.state.storage_at(&self.address, key)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn sstore(&mut self, index: H256, value: H256) {
|
/// Stores a value for given key.
|
||||||
println!("index: {:?}, value: {:?}", index, value);
|
pub fn sstore(&mut self, key: H256, value: H256) {
|
||||||
self.state.set_storage(&self.address, index, value)
|
self.state.set_storage(&self.address, key, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn balance(&self, _address: &Address) -> U256 {
|
/// Returns address balance.
|
||||||
unimplemented!();
|
pub fn balance(&self, address: &Address) -> U256 {
|
||||||
|
self.state.balance(address)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn blockhash(&self, _number: &U256) -> H256 {
|
pub fn blockhash(&self, _number: &U256) -> H256 {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
//! EVM interface
|
//! Evm interface.
|
||||||
|
|
||||||
use evm::{RuntimeData, Env};
|
use evm::{RuntimeData, Env};
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
//! Immutable runtime data.
|
||||||
|
|
||||||
use util::hash::*;
|
use util::hash::*;
|
||||||
use util::uint::*;
|
use util::uint::*;
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
//! Vm factory.
|
//! Evm factory.
|
||||||
|
|
||||||
use evm::Evm;
|
use evm::Evm;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user