Removing
This commit is contained in:
parent
2b4653ee35
commit
8a2db83803
@ -1,26 +1,35 @@
|
|||||||
//! Evm factory.
|
//! Evm factory.
|
||||||
//!
|
//!
|
||||||
//! TODO: consider spliting it into two separate files.
|
//! TODO: consider spliting it into two separate files.
|
||||||
|
#[cfg(test)]
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use evm::Evm;
|
use evm::Evm;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
/// Type of EVM to use.
|
/// Type of EVM to use.
|
||||||
pub enum VMType {
|
pub enum VMType {
|
||||||
#[allow(dead_code)] // crated only by jit
|
|
||||||
/// JIT EVM
|
/// JIT EVM
|
||||||
|
#[cfg(feature="jit")]
|
||||||
Jit,
|
Jit,
|
||||||
/// RUST EVM
|
/// RUST EVM
|
||||||
Interpreter
|
Interpreter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
impl fmt::Display for VMType {
|
impl fmt::Display for VMType {
|
||||||
|
#[cfg(feature="jit")]
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
write!(f, "{}", match *self {
|
write!(f, "{}", match *self {
|
||||||
VMType::Jit => "JIT",
|
VMType::Jit => "JIT",
|
||||||
VMType::Interpreter => "INT"
|
VMType::Interpreter => "INT"
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
#[cfg(not(feature="jit"))]
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
write!(f, "{}", match *self {
|
||||||
|
VMType::Interpreter => "INT"
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
@ -46,10 +55,12 @@ pub struct Factory {
|
|||||||
|
|
||||||
impl Factory {
|
impl Factory {
|
||||||
/// Create fresh instance of VM
|
/// Create fresh instance of VM
|
||||||
|
#[cfg(test)]
|
||||||
|
#[cfg(feature="jit")]
|
||||||
pub fn create(&self) -> Box<Evm> {
|
pub fn create(&self) -> Box<Evm> {
|
||||||
match self.evm {
|
match self.evm {
|
||||||
VMType::Jit => {
|
VMType::Jit => {
|
||||||
Factory::jit()
|
Box::new(super::jit::JitEvm)
|
||||||
},
|
},
|
||||||
VMType::Interpreter => {
|
VMType::Interpreter => {
|
||||||
Box::new(super::interpreter::Interpreter)
|
Box::new(super::interpreter::Interpreter)
|
||||||
@ -57,6 +68,16 @@ impl Factory {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Create fresh instance of VM
|
||||||
|
#[cfg(not(feature="jit"))]
|
||||||
|
pub fn create(&self) -> Box<Evm> {
|
||||||
|
match self.evm {
|
||||||
|
VMType::Interpreter => {
|
||||||
|
Box::new(super::interpreter::Interpreter)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Create new instance of specific `VMType` factory
|
/// Create new instance of specific `VMType` factory
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
pub fn new(evm: VMType) -> Factory {
|
pub fn new(evm: VMType) -> Factory {
|
||||||
@ -64,16 +85,6 @@ impl Factory {
|
|||||||
evm: evm
|
evm: evm
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "jit")]
|
|
||||||
fn jit() -> Box<Evm> {
|
|
||||||
Box::new(super::jit::JitEvm)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(not(feature = "jit"))]
|
|
||||||
fn jit() -> Box<Evm> {
|
|
||||||
unimplemented!()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
impl Default for Factory {
|
impl Default for Factory {
|
||||||
/// Returns jitvm factory
|
/// Returns jitvm factory
|
||||||
|
@ -11,7 +11,6 @@ pub struct StateDiff (BTreeMap<Address, AccountDiff>);
|
|||||||
impl StateDiff {
|
impl StateDiff {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
/// Calculate and return diff between `pre` state and `post` state.
|
/// Calculate and return diff between `pre` state and `post` state.
|
||||||
#[allow(dead_code)] // Used only in test code for now.
|
|
||||||
pub fn diff_pod(pre: &PodState, post: &PodState) -> StateDiff {
|
pub fn diff_pod(pre: &PodState, post: &PodState) -> StateDiff {
|
||||||
StateDiff(pre.get().keys().merge(post.get().keys()).filter_map(|acc| AccountDiff::diff_pod(pre.get().get(acc), post.get().get(acc)).map(|d|(acc.clone(), d))).collect())
|
StateDiff(pre.get().keys().merge(post.get().keys()).filter_map(|acc| AccountDiff::diff_pod(pre.get().get(acc), post.get().get(acc)).map(|d|(acc.clone(), d))).collect())
|
||||||
}
|
}
|
||||||
|
@ -46,10 +46,10 @@ impl Drop for RandomTempPath {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[cfg(test)]
|
||||||
pub struct GuardedTempResult<T> {
|
pub struct GuardedTempResult<T> {
|
||||||
result: T,
|
result: T,
|
||||||
temp: RandomTempPath
|
_temp: RandomTempPath
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> GuardedTempResult<T> {
|
impl<T> GuardedTempResult<T> {
|
||||||
@ -149,7 +149,7 @@ pub fn generate_dummy_client(block_number: u32) -> GuardedTempResult<Arc<Client>
|
|||||||
client.import_verified_blocks(&IoChannel::disconnected());
|
client.import_verified_blocks(&IoChannel::disconnected());
|
||||||
|
|
||||||
GuardedTempResult::<Arc<Client>> {
|
GuardedTempResult::<Arc<Client>> {
|
||||||
temp: dir,
|
_temp: dir,
|
||||||
result: client
|
result: client
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -167,7 +167,7 @@ pub fn get_test_client_with_blocks(blocks: Vec<Bytes>) -> GuardedTempResult<Arc<
|
|||||||
client.import_verified_blocks(&IoChannel::disconnected());
|
client.import_verified_blocks(&IoChannel::disconnected());
|
||||||
|
|
||||||
GuardedTempResult::<Arc<Client>> {
|
GuardedTempResult::<Arc<Client>> {
|
||||||
temp: dir,
|
_temp: dir,
|
||||||
result: client
|
result: client
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -180,7 +180,7 @@ pub fn generate_dummy_blockchain(block_number: u32) -> GuardedTempResult<BlockCh
|
|||||||
}
|
}
|
||||||
|
|
||||||
GuardedTempResult::<BlockChain> {
|
GuardedTempResult::<BlockChain> {
|
||||||
temp: temp,
|
_temp: temp,
|
||||||
result: bc
|
result: bc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -193,7 +193,7 @@ pub fn generate_dummy_blockchain_with_extra(block_number: u32) -> GuardedTempRes
|
|||||||
}
|
}
|
||||||
|
|
||||||
GuardedTempResult::<BlockChain> {
|
GuardedTempResult::<BlockChain> {
|
||||||
temp: temp,
|
_temp: temp,
|
||||||
result: bc
|
result: bc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -203,7 +203,7 @@ pub fn generate_dummy_empty_blockchain() -> GuardedTempResult<BlockChain> {
|
|||||||
let bc = BlockChain::new(&create_unverifiable_block(0, H256::zero()), temp.as_path());
|
let bc = BlockChain::new(&create_unverifiable_block(0, H256::zero()), temp.as_path());
|
||||||
|
|
||||||
GuardedTempResult::<BlockChain> {
|
GuardedTempResult::<BlockChain> {
|
||||||
temp: temp,
|
_temp: temp,
|
||||||
result: bc
|
result: bc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -213,7 +213,7 @@ pub fn get_temp_journal_db() -> GuardedTempResult<JournalDB> {
|
|||||||
let db = DB::open_default(temp.as_str()).unwrap();
|
let db = DB::open_default(temp.as_str()).unwrap();
|
||||||
let journal_db = JournalDB::new(db);
|
let journal_db = JournalDB::new(db);
|
||||||
GuardedTempResult {
|
GuardedTempResult {
|
||||||
temp: temp,
|
_temp: temp,
|
||||||
result: journal_db
|
result: journal_db
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -222,7 +222,7 @@ pub fn get_temp_state() -> GuardedTempResult<State> {
|
|||||||
let temp = RandomTempPath::new();
|
let temp = RandomTempPath::new();
|
||||||
let journal_db = get_temp_journal_db_in(temp.as_path());
|
let journal_db = get_temp_journal_db_in(temp.as_path());
|
||||||
GuardedTempResult {
|
GuardedTempResult {
|
||||||
temp: temp,
|
_temp: temp,
|
||||||
result: State::new(journal_db, U256::from(0u8))
|
result: State::new(journal_db, U256::from(0u8))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user