alloy_rpc_types_eth/
raw_log.rs

1//! Ethereum log object.
2
3use alloy_primitives::{Address, Bloom, Bytes, B256};
4use alloy_rlp::{RlpDecodable, RlpEncodable};
5
6use alloc::vec::Vec;
7
8/// Ethereum Log
9#[derive(Clone, Debug, Default, PartialEq, Eq, RlpDecodable, RlpEncodable)]
10pub struct Log {
11    /// Contract that emitted this log.
12    pub address: Address,
13    /// Topics of the log. The number of logs depend on what `LOG` opcode is used.
14    pub topics: Vec<B256>,
15    /// Arbitrary length data.
16    pub data: Bytes,
17}
18
19/// Calculate receipt logs bloom.
20pub fn logs_bloom<'a, It>(logs: It) -> Bloom
21where
22    It: IntoIterator<Item = &'a Log>,
23{
24    let mut bloom = Bloom::ZERO;
25    for log in logs {
26        bloom.m3_2048(log.address.as_slice());
27        for topic in &log.topics {
28            bloom.m3_2048(topic.as_slice());
29        }
30    }
31    bloom
32}