bloom refactor (#7475)

* ethereum-types refactor in progress

* ethereum-types refactor in progress

* ethereum-types refactor in progress

* ethereum-types refactor in progress

* ethereum-types refactor finished

* cleanup bloom mess

* simplify usage of Bloom in few places

* removed obsolete util/src/lib.rs

* removed commented out code

* ethereum-types 0.1.4

* updated ethereum-types and tiny-keccak
This commit is contained in:
Marek Kotewicz
2018-01-14 22:43:28 +01:00
committed by GitHub
parent e7f36665bb
commit 668d910c44
65 changed files with 2023 additions and 519 deletions

View File

@@ -1,49 +0,0 @@
// Copyright 2015-2017 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
use bloomchain as bc;
use heapsize::HeapSizeOf;
use basic_types::LogBloom;
/// Helper structure representing bloom of the trace.
#[derive(Debug, Clone, RlpEncodableWrapper, RlpDecodableWrapper)]
pub struct Bloom(LogBloom);
impl From<LogBloom> for Bloom {
fn from(bloom: LogBloom) -> Self {
Bloom(bloom)
}
}
impl From<bc::Bloom> for Bloom {
fn from(bloom: bc::Bloom) -> Self {
let bytes: [u8; 256] = bloom.into();
Bloom(LogBloom::from(bytes))
}
}
impl Into<bc::Bloom> for Bloom {
fn into(self) -> bc::Bloom {
let log = self.0;
bc::Bloom::from(log.0)
}
}
impl HeapSizeOf for Bloom {
fn heap_size_of_children(&self) -> usize {
0
}
}

View File

@@ -15,12 +15,11 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
use bloomchain::group as bc;
use rlp::*;
use heapsize::HeapSizeOf;
use super::Bloom;
use ethereum_types::Bloom;
/// Represents group of X consecutive blooms.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, RlpEncodableWrapper, RlpDecodableWrapper)]
pub struct BloomGroup {
blooms: Vec<Bloom>,
}
@@ -51,22 +50,6 @@ impl Into<bc::BloomGroup> for BloomGroup {
}
}
impl Decodable for BloomGroup {
fn decode(rlp: &UntrustedRlp) -> Result<Self, DecoderError> {
let blooms = rlp.as_list()?;
let group = BloomGroup {
blooms: blooms
};
Ok(group)
}
}
impl Encodable for BloomGroup {
fn rlp_append(&self, s: &mut RlpStream) {
s.append_list(&self.blooms);
}
}
impl HeapSizeOf for BloomGroup {
fn heap_size_of_children(&self) -> usize {
self.blooms.heap_size_of_children()

View File

@@ -16,10 +16,8 @@
//! Bridge between bloomchain crate types and ethcore.
mod bloom;
mod bloom_group;
mod group_position;
pub use self::bloom::Bloom;
pub use self::bloom_group::BloomGroup;
pub use self::group_position::GroupPosition;