Skip to content

Commit 6a6e3f5

Browse files
authored
Fix topic wildcards bug (#277)
1 parent 761083c commit 6a6e3f5

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

client/rpc-core/src/types/filter.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,18 @@ impl FilteredParams {
272272
}
273273
}
274274
},
275-
VariadicValue::Multiple(_) => {
276-
let replaced: Option<Vec<H256>> = self.replace(log, topic);
275+
VariadicValue::Multiple(multi) => {
276+
// Shrink the topics until the last item is Some.
277+
let mut new_multi = multi;
278+
while new_multi.iter().last().unwrap_or(&Some(H256::default())).is_none() {
279+
new_multi.pop();
280+
}
281+
// We can discard right away any logs with lesser topics than the filter.
282+
if new_multi.len() > log.topics.len() {
283+
out = false;
284+
break;
285+
}
286+
let replaced: Option<Vec<H256>> = self.replace(log, VariadicValue::Multiple(new_multi));
277287
if let Some(replaced) = replaced {
278288
out = false;
279289
if log.topics.starts_with(

0 commit comments

Comments
 (0)