log_entry type.
This commit is contained in:
parent
42144247f5
commit
30f74fc692
@ -169,7 +169,7 @@ impl<'x, 'y> OpenBlock<'x, 'y> {
|
|||||||
/// If valid, it will be executed, and archived together with the receipt.
|
/// If valid, it will be executed, and archived together with the receipt.
|
||||||
pub fn push_transaction(&mut self, t: Transaction, h: Option<H256>) -> Result<&Receipt, Error> {
|
pub fn push_transaction(&mut self, t: Transaction, h: Option<H256>) -> Result<&Receipt, Error> {
|
||||||
let env_info = self.env_info();
|
let env_info = self.env_info();
|
||||||
match self.block.state.apply(&env_info, self.engine, &t, true) {
|
match self.block.state.apply(&env_info, self.engine, &t) {
|
||||||
Ok(x) => {
|
Ok(x) => {
|
||||||
self.block.archive_set.insert(h.unwrap_or_else(||t.hash()));
|
self.block.archive_set.insert(h.unwrap_or_else(||t.hash()));
|
||||||
self.block.archive.push(Entry { transaction: t, receipt: x.receipt });
|
self.block.archive.push(Entry { transaction: t, receipt: x.receipt });
|
||||||
|
@ -8,4 +8,5 @@ pub use builtin::*;
|
|||||||
pub use header::*;
|
pub use header::*;
|
||||||
pub use account::*;
|
pub use account::*;
|
||||||
pub use transaction::*;
|
pub use transaction::*;
|
||||||
|
pub use log_entry::*;
|
||||||
pub use receipt::*;
|
pub use receipt::*;
|
@ -88,6 +88,7 @@ extern crate ethcore_util as util;
|
|||||||
pub mod common;
|
pub mod common;
|
||||||
pub mod basic_types;
|
pub mod basic_types;
|
||||||
pub mod error;
|
pub mod error;
|
||||||
|
pub mod log_entry;
|
||||||
pub mod env_info;
|
pub mod env_info;
|
||||||
pub mod engine;
|
pub mod engine;
|
||||||
pub mod state;
|
pub mod state;
|
||||||
|
62
src/log_entry.rs
Normal file
62
src/log_entry.rs
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
use util::*;
|
||||||
|
use basic_types::LogBloom;
|
||||||
|
|
||||||
|
/// A single log's entry.
|
||||||
|
pub struct LogEntry {
|
||||||
|
pub address: Address,
|
||||||
|
pub topics: Vec<H256>,
|
||||||
|
pub data: Bytes,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RlpStandard for LogEntry {
|
||||||
|
fn rlp_append(&self, s: &mut RlpStream) {
|
||||||
|
s.append_list(3);
|
||||||
|
s.append(&self.address);
|
||||||
|
s.append(&self.topics);
|
||||||
|
s.append(&self.data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl LogEntry {
|
||||||
|
pub fn bloom(&self) -> LogBloom {
|
||||||
|
self.topics.iter().fold(LogBloom::from_bloomed(&self.address.sha3()), |b, t| b.with_bloomed(&t.sha3()))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Create a new log entry.
|
||||||
|
pub fn new(address: Address, topics: Vec<H256>, data: Bytes) -> LogEntry {
|
||||||
|
LogEntry {
|
||||||
|
address: address,
|
||||||
|
topics: topics,
|
||||||
|
data: data
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns reference to address.
|
||||||
|
pub fn address(&self) -> &Address {
|
||||||
|
&self.address
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns reference to topics.
|
||||||
|
pub fn topics(&self) -> &Vec<H256> {
|
||||||
|
&self.topics
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns reference to data.
|
||||||
|
pub fn data(&self) -> &Bytes {
|
||||||
|
&self.data
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use util::*;
|
||||||
|
use super::LogEntry;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_empty_log_bloom() {
|
||||||
|
let bloom = H2048::from_str("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap();
|
||||||
|
let address = Address::from_str("0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6").unwrap();
|
||||||
|
let log = LogEntry::new(address, vec![], vec![]);
|
||||||
|
assert_eq!(log.bloom(), bloom);
|
||||||
|
}
|
||||||
|
}
|
@ -1,27 +1,6 @@
|
|||||||
use util::*;
|
use util::*;
|
||||||
use basic_types::LogBloom;
|
use basic_types::LogBloom;
|
||||||
|
use log_entry::LogEntry;
|
||||||
/// A single log's entry.
|
|
||||||
pub struct LogEntry {
|
|
||||||
pub address: Address,
|
|
||||||
pub topics: Vec<H256>,
|
|
||||||
pub data: Bytes,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl RlpStandard for LogEntry {
|
|
||||||
fn rlp_append(&self, s: &mut RlpStream) {
|
|
||||||
s.append_list(3);
|
|
||||||
s.append(&self.address);
|
|
||||||
s.append(&self.topics);
|
|
||||||
s.append(&self.data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl LogEntry {
|
|
||||||
pub fn bloom(&self) -> LogBloom {
|
|
||||||
self.topics.iter().fold(LogBloom::from_bloomed(&self.address.sha3()), |b, t| b.with_bloomed(&t.sha3()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Information describing execution of a transaction.
|
/// Information describing execution of a transaction.
|
||||||
pub struct Receipt {
|
pub struct Receipt {
|
||||||
|
@ -134,7 +134,7 @@ impl State {
|
|||||||
|
|
||||||
/// Execute a given transaction.
|
/// Execute a given transaction.
|
||||||
/// This will change the state accordingly.
|
/// This will change the state accordingly.
|
||||||
pub fn apply(&mut self, _env_info: &EnvInfo, _engine: &Engine, _t: &Transaction, _is_permanent: bool) -> ApplyResult {
|
pub fn apply(&mut self, _env_info: &EnvInfo, _engine: &Engine, _t: &Transaction) -> ApplyResult {
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user