Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add logs_bloom #768

Merged
merged 2 commits into from
Oct 10, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion crates/primitives/src/log/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
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.m3_2048(log.address.as_slice());
for topic in log.topics() {
bloom.m3_2048(topic.as_slice());
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bloom.accrue_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
Loading