diff --git a/crates/primitives/src/lib.rs b/crates/primitives/src/lib.rs index b46e1eaee..c7f2f4335 100644 --- a/crates/primitives/src/lib.rs +++ b/crates/primitives/src/lib.rs @@ -42,7 +42,7 @@ mod common; pub use common::TxKind; mod log; -pub use log::{IntoLogData, Log, LogData}; +pub use log::{logs_bloom, IntoLogData, Log, LogData}; #[cfg(feature = "map")] pub mod map; diff --git a/crates/primitives/src/log/mod.rs b/crates/primitives/src/log/mod.rs index a9eacaeeb..712e1ca91 100644 --- a/crates/primitives/src/log/mod.rs +++ b/crates/primitives/src/log/mod.rs @@ -1,9 +1,18 @@ -use crate::{Address, Bytes, B256}; +use crate::{Address, Bloom, Bytes, B256}; use alloc::vec::Vec; #[cfg(feature = "serde")] mod serde; +/// Compute the logs bloom filter for the given logs. +pub fn logs_bloom<'a>(logs: impl IntoIterator) -> Bloom { + let mut bloom = Bloom::ZERO; + for log in logs { + bloom.accrue_log(log); + } + bloom +} + /// An Ethereum event log object. #[derive(Clone, Debug, Default, PartialEq, Eq, Hash)] #[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))]