2016-12-11 19:30:54 +01:00
|
|
|
// Copyright 2015, 2016 Parity Technologies (UK) Ltd.
|
2016-07-11 09:42:41 +02:00
|
|
|
// This file is part of Parity.
|
|
|
|
|
|
|
|
// Parity is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
|
|
|
|
// Parity is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
//! Externalities implementation.
|
|
|
|
|
2016-10-17 11:55:47 +02:00
|
|
|
use std::sync::Arc;
|
2016-07-11 09:42:41 +02:00
|
|
|
use std::collections::HashMap;
|
|
|
|
use util::{U256, H256, Address, Bytes, FixedHash};
|
|
|
|
use ethcore::client::EnvInfo;
|
2016-07-30 15:38:44 +02:00
|
|
|
use ethcore::evm::{self, Ext, ContractCreateResult, MessageCallResult, Schedule, CallType};
|
2016-07-11 09:42:41 +02:00
|
|
|
|
|
|
|
pub struct FakeExt {
|
|
|
|
schedule: Schedule,
|
|
|
|
store: HashMap<H256, H256>,
|
2016-10-17 11:55:47 +02:00
|
|
|
depth: usize,
|
2016-07-11 09:42:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Default for FakeExt {
|
|
|
|
fn default() -> Self {
|
|
|
|
FakeExt {
|
2016-10-27 19:29:23 +02:00
|
|
|
schedule: Schedule::new_homestead_gas_fix(),
|
2016-07-11 09:42:41 +02:00
|
|
|
store: HashMap::new(),
|
2016-10-17 11:55:47 +02:00
|
|
|
depth: 1,
|
2016-07-11 09:42:41 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Ext for FakeExt {
|
|
|
|
fn storage_at(&self, key: &H256) -> H256 {
|
|
|
|
self.store.get(key).unwrap_or(&H256::new()).clone()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_storage(&mut self, key: H256, value: H256) {
|
|
|
|
self.store.insert(key, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn exists(&self, _address: &Address) -> bool {
|
|
|
|
unimplemented!();
|
|
|
|
}
|
|
|
|
|
2016-11-03 22:22:25 +01:00
|
|
|
fn exists_and_not_null(&self, address: &Address) -> bool {
|
|
|
|
unimplemented!();
|
|
|
|
}
|
|
|
|
|
|
|
|
fn origin_balance(&self) -> U256 {
|
|
|
|
unimplemented!();
|
|
|
|
}
|
|
|
|
|
2016-07-11 09:42:41 +02:00
|
|
|
fn balance(&self, _address: &Address) -> U256 {
|
|
|
|
unimplemented!();
|
|
|
|
}
|
|
|
|
|
|
|
|
fn blockhash(&self, _number: &U256) -> H256 {
|
|
|
|
unimplemented!();
|
|
|
|
}
|
|
|
|
|
|
|
|
fn create(&mut self, _gas: &U256, _value: &U256, _code: &[u8]) -> ContractCreateResult {
|
|
|
|
unimplemented!();
|
|
|
|
}
|
|
|
|
|
|
|
|
fn call(&mut self,
|
|
|
|
_gas: &U256,
|
|
|
|
_sender_address: &Address,
|
|
|
|
_receive_address: &Address,
|
|
|
|
_value: Option<U256>,
|
|
|
|
_data: &[u8],
|
|
|
|
_code_address: &Address,
|
2016-07-30 15:38:44 +02:00
|
|
|
_output: &mut [u8],
|
|
|
|
_call_type: CallType) -> MessageCallResult {
|
2016-07-11 09:42:41 +02:00
|
|
|
unimplemented!();
|
|
|
|
}
|
|
|
|
|
2016-10-17 11:55:47 +02:00
|
|
|
fn extcode(&self, _address: &Address) -> Arc<Bytes> {
|
|
|
|
unimplemented!();
|
|
|
|
}
|
|
|
|
|
|
|
|
fn extcodesize(&self, _address: &Address) -> usize {
|
2016-07-11 09:42:41 +02:00
|
|
|
unimplemented!();
|
|
|
|
}
|
|
|
|
|
|
|
|
fn log(&mut self, _topics: Vec<H256>, _data: &[u8]) {
|
|
|
|
unimplemented!();
|
|
|
|
}
|
|
|
|
|
|
|
|
fn ret(self, gas: &U256, _data: &[u8]) -> evm::Result<U256> {
|
|
|
|
Ok(*gas)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn suicide(&mut self, _refund_address: &Address) {
|
|
|
|
unimplemented!();
|
|
|
|
}
|
|
|
|
|
|
|
|
fn schedule(&self) -> &Schedule {
|
|
|
|
&self.schedule
|
|
|
|
}
|
|
|
|
|
|
|
|
fn env_info(&self) -> &EnvInfo {
|
|
|
|
unimplemented!()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn depth(&self) -> usize {
|
2016-10-17 11:55:47 +02:00
|
|
|
self.depth
|
2016-07-11 09:42:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
fn inc_sstore_clears(&mut self) {
|
|
|
|
unimplemented!();
|
|
|
|
// self.sstore_clears += 1;
|
|
|
|
}
|
|
|
|
}
|