Skip to content
This repository was archived by the owner on Nov 6, 2020. It is now read-only.
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
14 changes: 11 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ members = [
"util/triehash-ethereum",
"util/keccak-hasher",
"util/patricia-trie-ethereum",
"util/fastmap",
]

[patch.crates-io]
Expand Down
2 changes: 1 addition & 1 deletion ethcore/light/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ ethcore-io = { path = "../../util/io" }
hashdb = { git = "https://github.com/paritytech/parity-common" }
heapsize = "0.4"
vm = { path = "../vm" }
plain_hasher = { git = "https://github.com/paritytech/parity-common" }
fastmap = { path = "../../util/fastmap" }
rlp = { git = "https://github.com/paritytech/parity-common" }
rlp_derive = { path = "../../util/rlp_derive" }
smallvec = "0.4"
Expand Down
2 changes: 1 addition & 1 deletion ethcore/light/src/client/header_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ use ethereum_types::{H256, H264, U256};
use heapsize::HeapSizeOf;
use kvdb::{DBTransaction, KeyValueDB};
use parking_lot::{Mutex, RwLock};
use plain_hasher::H256FastMap;
use fastmap::H256FastMap;
use rlp::{Encodable, Decodable, DecoderError, RlpStream, Rlp};
use smallvec::SmallVec;

Expand Down
2 changes: 1 addition & 1 deletion ethcore/light/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ extern crate keccak_hasher;
extern crate memorydb;
extern crate patricia_trie as trie;
extern crate patricia_trie_ethereum as ethtrie;
extern crate plain_hasher;
extern crate fastmap;
extern crate rand;
extern crate rlp;
extern crate parking_lot;
Expand Down
2 changes: 1 addition & 1 deletion ethcore/light/src/transaction_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use std::collections::hash_map::Entry;

use transaction::{self, Condition, PendingTransaction, SignedTransaction};
use ethereum_types::{H256, U256, Address};
use plain_hasher::H256FastMap;
use fastmap::H256FastMap;

// Knowledge of an account's current nonce.
#[derive(Debug, Clone, PartialEq, Eq)]
Expand Down
2 changes: 1 addition & 1 deletion ethcore/sync/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ethcore-transaction = { path = "../transaction" }
ethcore = { path = ".." }
ethereum-types = "0.3"
hashdb = { git = "https://github.com/paritytech/parity-common" }
plain_hasher = { git = "https://github.com/paritytech/parity-common" }
fastmap = { path = "../../util/fastmap" }
rlp = { git = "https://github.com/paritytech/parity-common" }
rustc-hex = "1.0"
keccak-hash = { git = "https://github.com/paritytech/parity-common" }
Expand Down
2 changes: 1 addition & 1 deletion ethcore/sync/src/chain/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ use std::time::{Duration, Instant};
use hash::keccak;
use heapsize::HeapSizeOf;
use ethereum_types::{H256, U256};
use plain_hasher::H256FastMap;
use fastmap::H256FastMap;
use parking_lot::RwLock;
use bytes::Bytes;
use rlp::{Rlp, RlpStream, DecoderError};
Expand Down
2 changes: 1 addition & 1 deletion ethcore/sync/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ extern crate ethcore;
extern crate ethereum_types;
extern crate env_logger;
extern crate hashdb;
extern crate plain_hasher;
extern crate fastmap;
extern crate rand;
extern crate semver;
extern crate parking_lot;
Expand Down
2 changes: 1 addition & 1 deletion ethcore/sync/src/transactions_stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use api::TransactionStats;
use std::collections::{HashSet, HashMap};
use ethereum_types::{H256, H512};
use plain_hasher::H256FastMap;
use fastmap::H256FastMap;

type NodeId = H512;
type BlockNumber = u64;
Expand Down
10 changes: 10 additions & 0 deletions util/fastmap/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "fastmap"
version = "0.1.0"
authors = ["Parity Technologies <admin@parity.io>"]
description = "Specialized version of `HashMap` with H256 keys and fast hashing function."
license = "GPL-3.0"

[dependencies]
ethereum-types = "0.3"
plain_hasher = { git = "https://github.com/paritytech/parity-common" }
39 changes: 39 additions & 0 deletions util/fastmap/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright 2015-2018 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/>.

//! Provides a `H256FastMap` type with H256 keys and fast hashing function.

extern crate ethereum_types;
extern crate plain_hasher;

use ethereum_types::H256;
use std::hash;
use std::collections::HashMap;
use plain_hasher::PlainHasher;

/// Specialized version of `HashMap` with H256 keys and fast hashing function.
pub type H256FastMap<T> = HashMap<H256, T, hash::BuildHasherDefault<PlainHasher>>;

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn test_works() {
let mut h = H256FastMap::default();
h.insert(H256::from(123), "abc");
}
}
2 changes: 1 addition & 1 deletion util/journaldb/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ kvdb = { git = "https://github.com/paritytech/parity-common" }
log = "0.3"
memorydb = { git = "https://github.com/paritytech/parity-common" }
parking_lot = "0.6"
plain_hasher = { git = "https://github.com/paritytech/parity-common" }
fastmap = { path = "../../util/fastmap" }
rlp = { git = "https://github.com/paritytech/parity-common" }

[dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion util/journaldb/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ extern crate keccak_hasher;
extern crate kvdb;
extern crate memorydb;
extern crate parking_lot;
extern crate plain_hasher;
extern crate fastmap;
extern crate rlp;

#[cfg(test)]
Expand Down
2 changes: 1 addition & 1 deletion util/journaldb/src/overlayrecentdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use keccak_hasher::KeccakHasher;
use kvdb::{KeyValueDB, DBTransaction};
use memorydb::*;
use parking_lot::RwLock;
use plain_hasher::H256FastMap;
use fastmap::H256FastMap;
use rlp::{Rlp, RlpStream, encode, decode, DecoderError, Decodable, Encodable};
use super::{DB_PREFIX_LEN, LATEST_ERA_KEY, JournalDB, error_negatively_reference_hash};
use util::DatabaseKey;
Expand Down