Skip to content

Commit

Permalink
chore: replace fnv with fxhashmap (paradigmxyz#7927)
Browse files Browse the repository at this point in the history
mattsse authored Apr 27, 2024
1 parent 2deb259 commit 2b6921b
Showing 7 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion 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
@@ -321,6 +321,7 @@ serde_with = "3.3.0"
humantime = "2.1"
humantime-serde = "1.1"
rand = "0.8.5"
rustc-hash = "1.1.0"
schnellru = "0.2"
strum = "0.26"
rayon = "1.7"
2 changes: 1 addition & 1 deletion crates/storage/db/Cargo.toml
Original file line number Diff line number Diff line change
@@ -37,7 +37,7 @@ tempfile = { workspace = true, optional = true }
derive_more.workspace = true
eyre.workspace = true
paste.workspace = true
rustc-hash = "1.1.0"
rustc-hash.workspace = true

# arbitrary utils
arbitrary = { workspace = true, features = ["derive"], optional = true }
2 changes: 1 addition & 1 deletion crates/transaction-pool/Cargo.toml
Original file line number Diff line number Diff line change
@@ -36,9 +36,9 @@ metrics.workspace = true
aquamarine.workspace = true
thiserror.workspace = true
tracing.workspace = true
rustc-hash.workspace = true
schnellru.workspace = true
serde = { workspace = true, features = ["derive", "rc"], optional = true }
fnv = "1.0.7"
bitflags.workspace = true
auto_impl.workspace = true
smallvec.workspace = true
4 changes: 2 additions & 2 deletions crates/transaction-pool/src/identifier.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use fnv::FnvHashMap;
use reth_primitives::Address;
use rustc_hash::FxHashMap;
use std::collections::HashMap;

/// An internal mapping of addresses.
@@ -13,7 +13,7 @@ pub(crate) struct SenderIdentifiers {
/// Assigned `SenderId` for an `Address`.
address_to_id: HashMap<Address, SenderId>,
/// Reverse mapping of `SenderId` to `Address`.
sender_to_address: FnvHashMap<SenderId, Address>,
sender_to_address: FxHashMap<SenderId, Address>,
}

impl SenderIdentifiers {
4 changes: 2 additions & 2 deletions crates/transaction-pool/src/pool/parked.rs
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ use crate::{
pool::size::SizeTracker,
PoolTransaction, SubPoolLimit, ValidPoolTransaction, TXPOOL_MAX_ACCOUNT_SLOTS_PER_SENDER,
};
use fnv::FnvHashMap;
use rustc_hash::FxHashMap;
use smallvec::SmallVec;
use std::{
cmp::Ordering,
@@ -40,7 +40,7 @@ pub struct ParkedPool<T: ParkedOrd> {
last_sender_submission: BTreeSet<SubmissionSenderId>,
/// Keeps track of the number of transactions in the pool by the sender and the last submission
/// id.
sender_transaction_count: FnvHashMap<SenderId, SenderTransactionCount>,
sender_transaction_count: FxHashMap<SenderId, SenderTransactionCount>,
/// Keeps track of the size of this pool.
///
/// See also [`PoolTransaction::size`].
6 changes: 3 additions & 3 deletions crates/transaction-pool/src/pool/txpool.rs
Original file line number Diff line number Diff line change
@@ -18,14 +18,14 @@ use crate::{
PoolConfig, PoolResult, PoolTransaction, PriceBumpConfig, TransactionOrdering,
ValidPoolTransaction, U256,
};
use fnv::FnvHashMap;
use itertools::Itertools;
use reth_primitives::{
constants::{
eip4844::BLOB_TX_MIN_BLOB_GASPRICE, ETHEREUM_BLOCK_GAS_LIMIT, MIN_PROTOCOL_BASE_FEE,
},
Address, TxHash, B256,
};
use rustc_hash::FxHashMap;
use smallvec::SmallVec;
use std::{
cmp::Ordering,
@@ -44,7 +44,7 @@ use tracing::trace;
/// include_mmd!("docs/mermaid/txpool.mmd")
pub struct TxPool<T: TransactionOrdering> {
/// Contains the currently known information about the senders.
sender_info: FnvHashMap<SenderId, SenderInfo>,
sender_info: FxHashMap<SenderId, SenderInfo>,
/// pending subpool
///
/// Holds transactions that are ready to be executed on the current state.
@@ -903,7 +903,7 @@ pub(crate) struct AllTransactions<T: PoolTransaction> {
/// _All_ transaction in the pool sorted by their sender and nonce pair.
txs: BTreeMap<TransactionId, PoolInternalTransaction<T>>,
/// Tracks the number of transactions by sender that are currently in the pool.
tx_counter: FnvHashMap<SenderId, usize>,
tx_counter: FxHashMap<SenderId, usize>,
/// The current block number the pool keeps track of.
last_seen_block_number: u64,
/// The current block hash the pool keeps track of.

0 comments on commit 2b6921b

Please sign in to comment.