evm adapter init

This commit is contained in:
debris
2015-12-23 13:02:01 +01:00
parent 6c01295590
commit 353d4fbea0
6 changed files with 196 additions and 5 deletions

View File

@@ -4,5 +4,4 @@ version = "0.1.0"
authors = ["debris <marek.kotewicz@gmail.com>"]
[dependencies]
libc = "0.2.2"
tiny-keccak = "1.0"

View File

@@ -13,13 +13,13 @@
//!
//! ```
extern crate libc;
extern crate tiny_keccak;
use std::ops::{Deref, DerefMut};
use self::ffi::*;
pub use self::ffi::JitReturnCode as ReturnCode;
pub use self::ffi::JitI256 as I256;
/// Component oriented safe handle to `JitRuntimeData`.
pub struct RuntimeDataHandle {
@@ -51,6 +51,20 @@ impl Drop for RuntimeDataHandle {
}
}
impl Deref for RuntimeDataHandle {
type Target = JitRuntimeData;
fn deref(&self) -> &Self::Target {
self.runtime_data()
}
}
impl DerefMut for RuntimeDataHandle {
fn deref_mut(&mut self) -> &mut Self::Target {
self.mut_runtime_data()
}
}
/// Safe handle for jit context.
pub struct ContextHandle {
context: *mut JitContext,
@@ -156,7 +170,6 @@ impl DerefMut for EnvHandle {
/// ffi functions
pub mod ffi {
use std::slice;
use libc;
use tiny_keccak::Keccak;
use super::*;
@@ -178,6 +191,7 @@ pub mod ffi {
}
#[repr(C)]
#[derive(Debug)]
/// Signed 256 bit integer.
pub struct JitI256 {
pub words: [u64; 4]
@@ -188,7 +202,7 @@ pub mod ffi {
pub struct JitRuntimeData {
pub gas: i64,
pub gas_price: i64,
pub call_data: *const libc::c_char,
pub call_data: *const u8,
pub call_data_size: u64,
pub address: JitI256,
pub caller: JitI256,
@@ -199,7 +213,7 @@ pub mod ffi {
pub gas_limit: JitI256,
pub number: u64,
pub timestamp: i64,
pub code: *const libc::c_char,
pub code: *const u8,
pub code_size: u64,
pub code_hash: JitI256
}