block_core/
log.rs

1use rlp::{Encodable, Decodable, RlpStream, DecoderError, UntrustedRlp};
2use bigint::{Address, Gas, H256, U256, B256, H64};
3
4#[cfg(not(feature = "std"))]
5use alloc::vec::Vec;
6
7#[derive(Clone, Debug, PartialEq, Eq)]
8pub struct Log {
9    pub address: Address,
10    pub topics: Vec<H256>,
11    pub data: Vec<u8>,
12}
13
14impl Encodable for Log {
15    fn rlp_append(&self, s: &mut RlpStream) {
16        s.begin_list(3);
17        s.append(&self.address);
18        s.append_list(&self.topics);
19        s.append(&self.data);
20    }
21}
22
23impl Decodable for Log {
24    fn decode(rlp: &UntrustedRlp) -> Result<Self, DecoderError> {
25        Ok(Self {
26            address: rlp.val_at(0)?,
27            topics: rlp.list_at(1)?,
28            data: rlp.val_at(2)?,
29        })
30    }
31}