mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-02-19 03:04:27 -05:00
refactor: use alloy_primitives::map for all HashMap/HashSet types (#21686)
Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
committed by
GitHub
parent
98313a0bea
commit
f53f90d714
@@ -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()) }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user