Vec<u8> -> Bytes and clearing log API
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
//! Interface for Evm externalities.
|
||||
|
||||
use common::Bytes;
|
||||
use util::hash::*;
|
||||
use util::uint::*;
|
||||
use evm::{Schedule, Error};
|
||||
@@ -38,10 +39,10 @@ pub trait Ext {
|
||||
output: &mut [u8]) -> Result<(U256, bool), Error>;
|
||||
|
||||
/// Returns code at given address
|
||||
fn extcode(&self, address: &Address) -> Vec<u8>;
|
||||
fn extcode(&self, address: &Address) -> Bytes;
|
||||
|
||||
/// Creates log entry with given topics and data
|
||||
fn log(&mut self, topics: Vec<H256>, data: Vec<u8>);
|
||||
fn log(&mut self, topics: Vec<H256>, data: &[u8]);
|
||||
|
||||
/// Should be called when transaction calls `RETURN` opcode.
|
||||
/// Returns gas_left if cost of returning the data is not too high.
|
||||
|
||||
@@ -614,7 +614,7 @@ impl Interpreter {
|
||||
.iter()
|
||||
.map(H256::from)
|
||||
.collect();
|
||||
ext.log(topics, mem.read_slice(offset, size).to_vec());
|
||||
ext.log(topics, mem.read_slice(offset, size));
|
||||
},
|
||||
instructions::PUSH1...instructions::PUSH32 => {
|
||||
let bytes = instructions::get_push_bytes(instruction);
|
||||
|
||||
@@ -7,7 +7,7 @@ use evm;
|
||||
struct RuntimeData {
|
||||
gas: U256,
|
||||
gas_price: U256,
|
||||
call_data: Vec<u8>,
|
||||
call_data: Bytes,
|
||||
address: Address,
|
||||
caller: Address,
|
||||
origin: Address,
|
||||
@@ -17,7 +17,7 @@ struct RuntimeData {
|
||||
gas_limit: U256,
|
||||
number: u64,
|
||||
timestamp: u64,
|
||||
code: Vec<u8>
|
||||
code: Bytes
|
||||
}
|
||||
|
||||
impl RuntimeData {
|
||||
|
||||
@@ -66,14 +66,14 @@ impl Ext for FakeExt {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
fn extcode(&self, address: &Address) -> Vec<u8> {
|
||||
fn extcode(&self, address: &Address) -> Bytes {
|
||||
self.codes.get(address).unwrap_or(&Bytes::new()).clone()
|
||||
}
|
||||
|
||||
fn log(&mut self, topics: Vec<H256>, data: Vec<u8>) {
|
||||
fn log(&mut self, topics: Vec<H256>, data: &[u8]) {
|
||||
self.logs.push(FakeLogEntry {
|
||||
topics: topics,
|
||||
data: data
|
||||
data: data.to_vec()
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user