openethereum/src/lib.rs

143 lines
3.0 KiB
Rust
Raw Normal View History

2015-12-05 19:44:43 +01:00
//! Ethcore's ethereum implementation
//!
//! ### Rust version
//! - beta
//! - nightly
//!
//! ### Supported platforms:
//! - OSX
//! - Linux/Ubuntu
//!
//! ### Dependencies:
//! - RocksDB 3.13
//! - LLVM 3.7 (optional, required for `jit`)
//! - evmjit (optional, required for `jit`)
//!
//! ### Dependencies Installation
//!
//! - OSX
//!
//! - rocksdb
//! ```
//! brew install rocksdb
//! ```
//!
//! - llvm
//!
//! - download llvm 3.7 from http://llvm.org/apt/
//!
//! ```
//! cd llvm-3.7.0.src
//! mkdir build && cd $_
//! cmake -G "Unix Makefiles" .. -DCMAKE_C_FLAGS_RELEASE= -DCMAKE_CXX_FLAGS_RELEASE= -DCMAKE_INSTALL_PREFIX=/usr/local/Cellar/llvm/3.7 -DCMAKE_BUILD_TYPE=Release
//! make && make install
//! ```
//! - evmjit
//!
//! - download from https://github.com/debris/evmjit
//!
//! ```
//! cd evmjit
//! mkdir build && cd $_
//! cmake -DLLVM_DIR=/usr/local/lib/llvm-3.7/share/llvm/cmake ..
//! make && make install
//! ```
//!
//! - Linux/Ubuntu
//!
//! - rocksdb
//!
//! ```
//! wget https://github.com/facebook/rocksdb/archive/rocksdb-3.13.tar.gz
//! tar xvf rocksdb-3.13.tar.gz && cd rocksdb-rocksdb-3.13 && make shared_lib
//! sudo make install
//! ```
//!
//! - llvm
//!
//! - install using packages from http://llvm.org/apt/
//!
//! - evmjit
//!
//! - download from https://github.com/debris/evmjit
//!
//! ```
//! cd evmjit
//! mkdir build && cd $_
//! cmake .. && make
//! sudo make install
//! sudo ldconfig
//! ```
#[macro_use]
2015-12-05 19:21:07 +01:00
extern crate log;
extern crate env_logger;
2015-11-26 21:34:49 +01:00
extern crate ethcore_util;
2015-12-05 19:21:07 +01:00
#[cfg(feature = "jit" )]
extern crate evmjit;
2015-11-26 21:34:49 +01:00
//use ethcore_util::error::*;
2015-11-26 21:34:49 +01:00
use ethcore_util::hash::*;
2015-11-27 13:18:35 +01:00
use ethcore_util::uint::*;
use ethcore_util::bytes::*;
2015-11-26 21:34:49 +01:00
2015-12-05 17:32:36 +01:00
pub type LogBloom = H2048;
2015-11-26 21:34:49 +01:00
pub mod state;
2015-11-26 21:34:49 +01:00
2015-11-27 13:18:35 +01:00
pub static ZERO_ADDRESS: Address = Address([0x00; 20]);
2015-12-05 17:32:36 +01:00
pub static ZERO_H256: H256 = H256([0x00; 32]);
pub static ZERO_LOGBLOOM: LogBloom = H2048([0x00; 256]);
2015-11-26 21:34:49 +01:00
#[derive(Debug)]
pub struct Header {
2015-12-05 17:32:36 +01:00
parent_hash: H256,
2015-11-27 13:18:35 +01:00
timestamp: U256,
number: U256,
2015-11-26 21:34:49 +01:00
author: Address,
2015-12-05 17:32:36 +01:00
transactions_root: H256,
uncles_hash: H256,
extra_data_hash: H256,
2015-11-26 21:34:49 +01:00
2015-12-05 17:32:36 +01:00
state_root: H256,
receipts_root: H256,
2015-11-26 21:34:49 +01:00
log_bloom: LogBloom,
2015-11-27 13:18:35 +01:00
gas_used: U256,
gas_limit: U256,
2015-11-26 21:34:49 +01:00
2015-11-27 13:18:35 +01:00
difficulty: U256,
2015-11-26 21:34:49 +01:00
seal: Vec<Bytes>,
}
impl Header {
pub fn new() -> Header {
Header {
2015-12-05 17:32:36 +01:00
parent_hash: ZERO_H256.clone(),
timestamp: BAD_U256.clone(),
number: ZERO_U256.clone(),
author: ZERO_ADDRESS.clone(),
transactions_root: ZERO_H256.clone(),
uncles_hash: ZERO_H256.clone(),
extra_data_hash: ZERO_H256.clone(),
state_root: ZERO_H256.clone(),
receipts_root: ZERO_H256.clone(),
log_bloom: ZERO_LOGBLOOM.clone(),
gas_used: ZERO_U256.clone(),
gas_limit: ZERO_U256.clone(),
difficulty: ZERO_U256.clone(),
2015-11-26 21:34:49 +01:00
seal: vec![],
}
}
}
2015-11-24 22:21:15 +01:00
2015-11-27 00:30:33 +01:00
pub struct Transaction {
pub to: Address,
2015-11-27 13:18:35 +01:00
pub gas: U256,
2015-11-27 00:30:33 +01:00
pub data: Bytes,
pub code: Bytes,
}