Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion kvdb/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
//! Key-Value store abstraction with `RocksDB` backend.

extern crate elastic_array;
extern crate parity_bytes as bytes; // TODO: name changed; update upstream when `parity-common` is available
extern crate parity_bytes as bytes;

use std::io;
use std::path::Path;
Expand Down
11 changes: 7 additions & 4 deletions plain_hasher/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
[package]
name = "plain_hasher"
description = "Hasher for 32-bit keys."
version = "0.1.0"
version = "0.2.0"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
keywords = ["hash", "hasher"]
homepage = "https://github.com/paritytech/plain_hasher"
homepage = "https://github.com/paritytech/parity-common"
categories = [ "no-std"]

[dependencies]
crunchy = "0.1.6"
ethereum-types = "0.3"
hashdb = { path = "../hashdb" }

[features]
default = ["std"]
std = []
5 changes: 5 additions & 0 deletions plain_hasher/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Specialized Hasher for 32-bit keys

Provides `PlainHasher`, a specialized `core::hash::Hasher` that takes just 8 bytes of the provided value and may only be used for keys which are 32 bytes.

The crate is `no_std`-compatible.
17 changes: 6 additions & 11 deletions plain_hasher/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,15 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

#![cfg_attr(not(feature = "std"), no_std)]

#[macro_use]
extern crate crunchy;
extern crate ethereum_types;
extern crate hashdb;

use ethereum_types::H256;
// use hashdb::Hasher;
use std::hash;
use std::collections::{HashMap, HashSet};
/// Specialized version of `HashMap` with H256 keys and fast hashing function.
pub type H256FastMap<T> = HashMap<H256, T, hash::BuildHasherDefault<PlainHasher>>;
/// Specialized version of `HashSet` with H256 keys and fast hashing function.
pub type H256FastSet = HashSet<H256, hash::BuildHasherDefault<PlainHasher>>;
#[cfg(feature = "std")]
extern crate core;

use core::hash;
/// Hasher that just takes 8 bytes of the provided value.
/// May only be used for keys which are 32 bytes.
#[derive(Default)]
Expand All @@ -50,7 +45,7 @@ impl hash::Hasher for PlainHasher {

unroll! {
for _i in 0..8 {
unsafe {
unsafe {
*prefix_ptr ^= (*bytes_ptr ^ *bytes_ptr.offset(8)) ^ (*bytes_ptr.offset(16) ^ *bytes_ptr.offset(24));
bytes_ptr = bytes_ptr.offset(1);
prefix_ptr = prefix_ptr.offset(1);
Expand Down
13 changes: 0 additions & 13 deletions plain_hasher/util/plain_hasher/Cargo.toml

This file was deleted.

2 changes: 1 addition & 1 deletion test-support/keccak-hasher/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ license = "GPL-3.0"
ethereum-types = "0.3"
tiny-keccak = "1.4.2"
hashdb = { version = "0.2.0", path = "../../hashdb" }
plain_hasher = { version = "0.1.0", path = "../../plain_hasher" }
plain_hasher = { path = "../../plain_hasher" }
1 change: 0 additions & 1 deletion triehash/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ license = "GPL-3.0"

[dependencies]
elastic-array = "0.10"
ethereum-types = "0.3"
hashdb = { version = "0.2", path = "../hashdb" }
rlp = { version = "0.2.1", path = "../rlp" }

Expand Down
1 change: 0 additions & 1 deletion triehash/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
//! This module should be used to generate trie root hash.

extern crate elastic_array;
extern crate ethereum_types;
extern crate hashdb;
extern crate rlp;
#[cfg(test)] extern crate keccak_hasher;
Expand Down