openethereum/src/receipt.rs

44 lines
1.0 KiB
Rust
Raw Normal View History

use util::*;
use basic_types::LogBloom;
2016-01-11 13:29:15 +01:00
use log_entry::LogEntry;
/// Information describing execution of a transaction.
#[derive(Default, Debug, Clone)]
pub struct Receipt {
2016-01-19 17:02:01 +01:00
/// TODO [Gav Wood] Please document me
pub state_root: H256,
2016-01-19 17:02:01 +01:00
/// TODO [Gav Wood] Please document me
2016-01-08 22:04:21 +01:00
pub gas_used: U256,
2016-01-19 17:02:01 +01:00
/// TODO [Gav Wood] Please document me
pub log_bloom: LogBloom,
2016-01-19 17:02:01 +01:00
/// TODO [Gav Wood] Please document me
pub logs: Vec<LogEntry>,
}
2016-01-11 17:37:22 +01:00
impl Receipt {
2016-01-19 17:02:01 +01:00
/// TODO [Gav Wood] Please document me
2016-01-11 17:37:22 +01:00
pub fn new(state_root: H256, gas_used: U256, logs: Vec<LogEntry>) -> Receipt {
Receipt {
state_root: state_root,
gas_used: gas_used,
log_bloom: logs.iter().fold(LogBloom::new(), |mut b, l| { b |= &l.bloom(); b }),
logs: logs,
}
}
}
impl RlpStandard for Receipt {
fn rlp_append(&self, s: &mut RlpStream) {
s.append_list(4);
s.append(&self.state_root);
s.append(&self.gas_used);
s.append(&self.log_bloom);
// TODO: make work:
//s.append(&self.logs);
s.append_list(self.logs.len());
2016-01-17 15:56:09 +01:00
for l in &self.logs {
l.rlp_append(s);
}
}
}