Vec<u8> -> Bytes and clearing log API
This commit is contained in:
parent
09c46be74d
commit
79c1cc02f7
@ -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()
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -187,7 +187,7 @@ impl<'a> Ext for Externalities<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
fn extcode(&self, address: &Address) -> Vec<u8> {
|
||||
fn extcode(&self, address: &Address) -> Bytes {
|
||||
self.state.code(address).unwrap_or(vec![])
|
||||
}
|
||||
|
||||
@ -227,9 +227,9 @@ impl<'a> Ext for Externalities<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
fn log(&mut self, topics: Vec<H256>, data: Bytes) {
|
||||
fn log(&mut self, topics: Vec<H256>, data: &[u8]) {
|
||||
let address = self.params.address.clone();
|
||||
self.substate.logs.push(LogEntry::new(address, topics, data));
|
||||
self.substate.logs.push(LogEntry::new(address, topics, data.to_vec()));
|
||||
}
|
||||
|
||||
fn suicide(&mut self, refund_address: &Address) {
|
||||
|
@ -101,7 +101,7 @@ impl State {
|
||||
}
|
||||
|
||||
/// Mutate storage of account `a` so that it is `value` for `key`.
|
||||
pub fn code(&self, a: &Address) -> Option<Vec<u8>> {
|
||||
pub fn code(&self, a: &Address) -> Option<Bytes> {
|
||||
self.get(a, true).as_ref().map(|a|a.code().map(|x|x.to_vec())).unwrap_or(None)
|
||||
}
|
||||
|
||||
|
@ -132,11 +132,11 @@ impl<'a> Ext for TestExt<'a> {
|
||||
res
|
||||
}
|
||||
|
||||
fn extcode(&self, address: &Address) -> Vec<u8> {
|
||||
fn extcode(&self, address: &Address) -> Bytes {
|
||||
self.ext.extcode(address)
|
||||
}
|
||||
|
||||
fn log(&mut self, topics: Vec<H256>, data: Vec<u8>) {
|
||||
fn log(&mut self, topics: Vec<H256>, data: &[u8]) {
|
||||
self.ext.log(topics, data)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user