refactor: use alloy_primitives::map for all HashMap/HashSet types (#21686)

Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
Georgios Konstantopoulos
2026-02-04 04:08:39 -08:00
committed by GitHub
parent 98313a0bea
commit f53f90d714
56 changed files with 290 additions and 281 deletions

View File

@@ -2,16 +2,16 @@
//! signers to the genesis block.
use alloy_genesis::GenesisAccount;
use alloy_primitives::{Address, Bytes, B256, U256};
use alloy_primitives::{
map::{AddressMap, Entry},
Address, Bytes, B256, U256,
};
use reth_primitives_traits::crypto::secp256k1::public_key_to_address;
use secp256k1::{
rand::{thread_rng, RngCore},
Keypair, Secp256k1,
};
use std::{
collections::{hash_map::Entry, BTreeMap, HashMap},
fmt,
};
use std::{collections::BTreeMap, fmt};
/// This helps create a custom genesis alloc by making it easy to add funded accounts with known
/// signers to the genesis block.
@@ -43,7 +43,7 @@ use std::{
/// ```
pub struct GenesisAllocator<'a> {
/// The genesis alloc to be built.
alloc: HashMap<Address, GenesisAccount>,
alloc: AddressMap<GenesisAccount>,
/// The rng to use for generating key pairs.
rng: Box<dyn RngCore + 'a>,
}
@@ -54,7 +54,7 @@ impl<'a> GenesisAllocator<'a> {
where
R: RngCore,
{
Self { alloc: HashMap::default(), rng: Box::new(rng) }
Self { alloc: AddressMap::default(), rng: Box::new(rng) }
}
/// Use the provided rng for generating key pairs.
@@ -189,14 +189,14 @@ impl<'a> GenesisAllocator<'a> {
}
/// Build the genesis alloc.
pub fn build(self) -> HashMap<Address, GenesisAccount> {
pub fn build(self) -> AddressMap<GenesisAccount> {
self.alloc
}
}
impl Default for GenesisAllocator<'_> {
fn default() -> Self {
Self { alloc: HashMap::default(), rng: Box::new(thread_rng()) }
Self { alloc: AddressMap::default(), rng: Box::new(thread_rng()) }
}
}