Skip to content

Commit

Permalink
feat: add logs_bloom (#768)
Browse files Browse the repository at this point in the history
* feat: add logs_bloom

* accrue_log
  • Loading branch information
mattsse authored Oct 10, 2024
1 parent 7490294 commit 0441d79
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion crates/primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
11 changes: 10 additions & 1 deletion crates/primitives/src/log/mod.rs
Original file line number Diff line number Diff line change
@@ -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<Item = &'a Log>) -> 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))]
Expand Down

0 comments on commit 0441d79

Please sign in to comment.