removed redundant Bloom conversions (#7932)

* removed redundant Bloom conversions

* fixed broken tests
This commit is contained in:
Marek Kotewicz 2018-02-19 14:08:33 +01:00 committed by André Silva
parent d6d6a7cc95
commit 5b4abec2db
3 changed files with 7 additions and 22 deletions

View File

@ -353,7 +353,7 @@ impl BlockProvider for BlockChain {
fn blocks_with_bloom(&self, bloom: &Bloom, from_block: BlockNumber, to_block: BlockNumber) -> Vec<BlockNumber> {
let range = from_block as bc::Number..to_block as bc::Number;
let chain = bc::group::BloomGroupChain::new(self.blooms_config, self);
chain.with_bloom(&range, &Bloom::from(bloom.clone()).into())
chain.with_bloom(&range, bloom)
.into_iter()
.map(|b| b as BlockNumber)
.collect()
@ -1272,7 +1272,7 @@ impl BlockChain {
HashMap::new()
} else {
let chain = bc::group::BloomGroupChain::new(self.blooms_config, self);
chain.insert(info.number as bc::Number, Bloom::from(log_bloom).into())
chain.insert(info.number as bc::Number, log_bloom)
}
},
BlockLocation::BranchBecomingCanonChain(ref data) => {
@ -1280,14 +1280,12 @@ impl BlockChain {
let start_number = ancestor_number + 1;
let range = start_number as bc::Number..self.best_block_number() as bc::Number;
let mut blooms: Vec<bc::Bloom> = data.enacted.iter()
let mut blooms: Vec<Bloom> = data.enacted.iter()
.map(|hash| self.block_header_data(hash).unwrap())
.map(|h| h.log_bloom())
.map(Bloom::from)
.map(Into::into)
.collect();
blooms.push(Bloom::from(header.log_bloom()).into());
blooms.push(header.log_bloom());
let chain = bc::group::BloomGroupChain::new(self.blooms_config, self);
chain.replace(&range, blooms)

View File

@ -26,26 +26,16 @@ pub struct BloomGroup {
impl From<bc::BloomGroup> for BloomGroup {
fn from(group: bc::BloomGroup) -> Self {
let blooms = group.blooms
.into_iter()
.map(From::from)
.collect();
BloomGroup {
blooms: blooms
blooms: group.blooms
}
}
}
impl Into<bc::BloomGroup> for BloomGroup {
fn into(self) -> bc::BloomGroup {
let blooms = self.blooms
.into_iter()
.map(Into::into)
.collect();
bc::BloomGroup {
blooms: blooms
blooms: self.blooms
}
}
}

View File

@ -65,7 +65,7 @@ impl AddressesFilter {
.into_iter()
.flat_map(|bloom| self.list.iter()
.map(|address| {
let mut bloom = Bloom::from(bloom.0);
let mut bloom = bloom.clone();
bloom.accrue(BloomInput::Raw(address));
bloom
})
@ -91,9 +91,6 @@ pub struct Filter {
impl BloomFilter for Filter {
fn bloom_possibilities(&self) -> Vec<Bloom> {
self.bloom_possibilities()
.into_iter()
.map(|b| Bloom::from(b.0))
.collect()
}
fn range(&self) -> Range<Number> {