Merge branch 'master' into refactor/rlp-optionally-independent-of-ethereum-types
* master: Add a README, categorize as "no-std", version bump: 0.2 Remove dep on ethereum-types and make no_std compatible
This commit is contained in:
commit
883dd06468
|
@ -1,13 +1,16 @@
|
||||||
[package]
|
[package]
|
||||||
name = "plain_hasher"
|
name = "plain_hasher"
|
||||||
description = "Hasher for 32-bit keys."
|
description = "Hasher for 32-bit keys."
|
||||||
version = "0.1.0"
|
version = "0.2.0"
|
||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
authors = ["Parity Technologies <admin@parity.io>"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
keywords = ["hash", "hasher"]
|
keywords = ["hash", "hasher"]
|
||||||
homepage = "https://github.com/paritytech/plain_hasher"
|
homepage = "https://github.com/paritytech/parity-common"
|
||||||
|
categories = [ "no-std"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
crunchy = "0.1.6"
|
crunchy = "0.1.6"
|
||||||
ethereum-types = "0.3"
|
|
||||||
hashdb = { path = "../hashdb" }
|
[features]
|
||||||
|
default = ["std"]
|
||||||
|
std = []
|
|
@ -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.
|
|
@ -14,20 +14,15 @@
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#![cfg_attr(not(feature = "std"), no_std)]
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate crunchy;
|
extern crate crunchy;
|
||||||
extern crate ethereum_types;
|
|
||||||
extern crate hashdb;
|
|
||||||
|
|
||||||
use ethereum_types::H256;
|
#[cfg(feature = "std")]
|
||||||
// use hashdb::Hasher;
|
extern crate core;
|
||||||
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>>;
|
|
||||||
|
|
||||||
|
use core::hash;
|
||||||
/// Hasher that just takes 8 bytes of the provided value.
|
/// Hasher that just takes 8 bytes of the provided value.
|
||||||
/// May only be used for keys which are 32 bytes.
|
/// May only be used for keys which are 32 bytes.
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
|
|
|
@ -10,4 +10,4 @@ license = "GPL-3.0"
|
||||||
ethereum-types = "0.3"
|
ethereum-types = "0.3"
|
||||||
tiny-keccak = "1.4.2"
|
tiny-keccak = "1.4.2"
|
||||||
hashdb = { version = "0.2.0", path = "../../hashdb" }
|
hashdb = { version = "0.2.0", path = "../../hashdb" }
|
||||||
plain_hasher = { version = "0.1.0", path = "../../plain_hasher" }
|
plain_hasher = { path = "../../plain_hasher" }
|
Loading…
Reference in New Issue