Skip to content

Commit

Permalink
Merge pull request #244 from rustaceanrob/filter-12-18
Browse files Browse the repository at this point in the history
Remove unnecessary `async` from `Filter::contains_any`
  • Loading branch information
rustaceanrob authored Dec 19, 2024
2 parents 06a551c + 01c4fe5 commit 2198291
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 8 deletions.
2 changes: 1 addition & 1 deletion example/managed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ async fn main() {
tracing::info!("Connected to all required peers");
}
NodeMessage::IndexedFilter(mut filter) => {
if filter.contains_any(&addresses).await {
if filter.contains_any(&addresses) {
let hash = *filter.block_hash();
tracing::info!("Found script at {}!", hash);
let indexed_block = client.get_block(hash).await.unwrap();
Expand Down
1 change: 0 additions & 1 deletion src/chain/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,6 @@ impl<H: HeaderStore> Chain<H> {
if !self.block_queue.contains(&filter_message.block_hash)
&& filter
.contains_any(&self.scripts)
.await
.map_err(CFilterSyncError::Filter)?
{
// Add to the block queue
Expand Down
5 changes: 1 addition & 4 deletions src/filters/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@ impl Filter {
&self.block_hash
}

pub async fn contains_any(
&mut self,
scripts: &HashSet<ScriptBuf>,
) -> Result<bool, FilterError> {
pub fn contains_any(&mut self, scripts: &HashSet<ScriptBuf>) -> Result<bool, FilterError> {
self.block_filter
.match_any(
&self.block_hash,
Expand Down
3 changes: 1 addition & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,9 @@ impl IndexedFilter {
}

/// Does the filter contain a positive match for any of the provided scripts
pub async fn contains_any(&mut self, scripts: &HashSet<ScriptBuf>) -> bool {
pub fn contains_any(&mut self, scripts: &HashSet<ScriptBuf>) -> bool {
self.filter
.contains_any(scripts)
.await
.expect("vec reader is infallible")
}
}
Expand Down

0 comments on commit 2198291

Please sign in to comment.