Merge pull request #564 from ethcore/inclusive_bloom_ranges

chainfilter shouldnt exclude to_block from results
This commit is contained in:
Gav Wood 2016-03-02 13:05:45 +01:00
commit 3b3399ccc3
2 changed files with 20 additions and 20 deletions

View File

@ -88,7 +88,7 @@ impl<'a, D> ChainFilter<'a, D> where D: FilterDataSource
None => return None, None => return None,
Some(level_bloom) => match level { Some(level_bloom) => match level {
// if we are on the lowest level // if we are on the lowest level
0 => return match offset < to_block { 0 => return match offset <= to_block {
// take the value if its smaller than to_block // take the value if its smaller than to_block
true if level_bloom.contains(bloom) => Some(vec![offset]), true if level_bloom.contains(bloom) => Some(vec![offset]),
// return None if it is is equal to to_block // return None if it is is equal to to_block

View File

@ -81,13 +81,13 @@ fn test_topic_basic_search() {
{ {
let filter = ChainFilter::new(&cache, index_size, bloom_levels); let filter = ChainFilter::new(&cache, index_size, bloom_levels);
let blocks = filter.blocks_with_bloom(&to_bloom(&topic), 0, 23); let blocks = filter.blocks_with_bloom(&to_bloom(&topic), 0, 22);
assert_eq!(blocks.len(), 0); assert_eq!(blocks.len(), 0);
} }
{ {
let filter = ChainFilter::new(&cache, index_size, bloom_levels); let filter = ChainFilter::new(&cache, index_size, bloom_levels);
let blocks = filter.blocks_with_bloom(&to_bloom(&topic), 23, 24); let blocks = filter.blocks_with_bloom(&to_bloom(&topic), 23, 23);
assert_eq!(blocks.len(), 1); assert_eq!(blocks.len(), 1);
assert_eq!(blocks[0], 23); assert_eq!(blocks[0], 23);
} }
@ -235,11 +235,11 @@ fn test_chainfilter_real_data_short_searches() {
for_each_log(include_bytes!("logs.txt"), | block_number, address, topics | { for_each_log(include_bytes!("logs.txt"), | block_number, address, topics | {
println!("block_number: {:?}", block_number); println!("block_number: {:?}", block_number);
let filter = ChainFilter::new(&cache, index_size, bloom_levels); let filter = ChainFilter::new(&cache, index_size, bloom_levels);
let blocks = filter.blocks_with_bloom(&to_bloom(address), block_number, block_number + 1); let blocks = filter.blocks_with_bloom(&to_bloom(address), block_number, block_number);
assert_eq!(blocks.len(), 1); assert_eq!(blocks.len(), 1);
for (i, topic) in topics.iter().enumerate() { for (i, topic) in topics.iter().enumerate() {
println!("topic: {:?}", i); println!("topic: {:?}", i);
let blocks = filter.blocks_with_bloom(&to_bloom(topic), block_number, block_number + 1); let blocks = filter.blocks_with_bloom(&to_bloom(topic), block_number, block_number);
assert_eq!(blocks.len(), 1); assert_eq!(blocks.len(), 1);
} }
}); });