removed redundant Bloom conversions (#7932)
* removed redundant Bloom conversions * fixed broken tests
This commit is contained in:
parent
d6d6a7cc95
commit
5b4abec2db
@ -353,7 +353,7 @@ impl BlockProvider for BlockChain {
|
|||||||
fn blocks_with_bloom(&self, bloom: &Bloom, from_block: BlockNumber, to_block: BlockNumber) -> Vec<BlockNumber> {
|
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 range = from_block as bc::Number..to_block as bc::Number;
|
||||||
let chain = bc::group::BloomGroupChain::new(self.blooms_config, self);
|
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()
|
.into_iter()
|
||||||
.map(|b| b as BlockNumber)
|
.map(|b| b as BlockNumber)
|
||||||
.collect()
|
.collect()
|
||||||
@ -1272,7 +1272,7 @@ impl BlockChain {
|
|||||||
HashMap::new()
|
HashMap::new()
|
||||||
} else {
|
} else {
|
||||||
let chain = bc::group::BloomGroupChain::new(self.blooms_config, self);
|
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) => {
|
BlockLocation::BranchBecomingCanonChain(ref data) => {
|
||||||
@ -1280,14 +1280,12 @@ impl BlockChain {
|
|||||||
let start_number = ancestor_number + 1;
|
let start_number = ancestor_number + 1;
|
||||||
let range = start_number as bc::Number..self.best_block_number() as bc::Number;
|
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(|hash| self.block_header_data(hash).unwrap())
|
||||||
.map(|h| h.log_bloom())
|
.map(|h| h.log_bloom())
|
||||||
.map(Bloom::from)
|
|
||||||
.map(Into::into)
|
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
blooms.push(Bloom::from(header.log_bloom()).into());
|
blooms.push(header.log_bloom());
|
||||||
|
|
||||||
let chain = bc::group::BloomGroupChain::new(self.blooms_config, self);
|
let chain = bc::group::BloomGroupChain::new(self.blooms_config, self);
|
||||||
chain.replace(&range, blooms)
|
chain.replace(&range, blooms)
|
||||||
|
@ -26,26 +26,16 @@ pub struct BloomGroup {
|
|||||||
|
|
||||||
impl From<bc::BloomGroup> for BloomGroup {
|
impl From<bc::BloomGroup> for BloomGroup {
|
||||||
fn from(group: bc::BloomGroup) -> Self {
|
fn from(group: bc::BloomGroup) -> Self {
|
||||||
let blooms = group.blooms
|
|
||||||
.into_iter()
|
|
||||||
.map(From::from)
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
BloomGroup {
|
BloomGroup {
|
||||||
blooms: blooms
|
blooms: group.blooms
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<bc::BloomGroup> for BloomGroup {
|
impl Into<bc::BloomGroup> for BloomGroup {
|
||||||
fn into(self) -> bc::BloomGroup {
|
fn into(self) -> bc::BloomGroup {
|
||||||
let blooms = self.blooms
|
|
||||||
.into_iter()
|
|
||||||
.map(Into::into)
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
bc::BloomGroup {
|
bc::BloomGroup {
|
||||||
blooms: blooms
|
blooms: self.blooms
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ impl AddressesFilter {
|
|||||||
.into_iter()
|
.into_iter()
|
||||||
.flat_map(|bloom| self.list.iter()
|
.flat_map(|bloom| self.list.iter()
|
||||||
.map(|address| {
|
.map(|address| {
|
||||||
let mut bloom = Bloom::from(bloom.0);
|
let mut bloom = bloom.clone();
|
||||||
bloom.accrue(BloomInput::Raw(address));
|
bloom.accrue(BloomInput::Raw(address));
|
||||||
bloom
|
bloom
|
||||||
})
|
})
|
||||||
@ -91,9 +91,6 @@ pub struct Filter {
|
|||||||
impl BloomFilter for Filter {
|
impl BloomFilter for Filter {
|
||||||
fn bloom_possibilities(&self) -> Vec<Bloom> {
|
fn bloom_possibilities(&self) -> Vec<Bloom> {
|
||||||
self.bloom_possibilities()
|
self.bloom_possibilities()
|
||||||
.into_iter()
|
|
||||||
.map(|b| Bloom::from(b.0))
|
|
||||||
.collect()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn range(&self) -> Range<Number> {
|
fn range(&self) -> Range<Number> {
|
||||||
|
Loading…
Reference in New Issue
Block a user