test: rm redundant helper trait (#7962)

This commit is contained in:
Matthias Seitz
2024-04-29 15:25:53 +02:00
committed by GitHub
parent b2c3d0c0b3
commit ee70351751
2 changed files with 12 additions and 9 deletions

View File

@ -7,7 +7,10 @@ use secp256k1::{
rand::{thread_rng, RngCore}, rand::{thread_rng, RngCore},
Keypair, Secp256k1, Keypair, Secp256k1,
}; };
use std::collections::{hash_map::Entry, BTreeMap, HashMap}; use std::{
collections::{hash_map::Entry, BTreeMap, HashMap},
fmt,
};
/// This helps create a custom genesis alloc by making it easy to add funded accounts with known /// This helps create a custom genesis alloc by making it easy to add funded accounts with known
/// signers to the genesis block. /// signers to the genesis block.
@ -37,19 +40,18 @@ use std::collections::{hash_map::Entry, BTreeMap, HashMap};
/// // Once you're done adding accounts, you can build the alloc. /// // Once you're done adding accounts, you can build the alloc.
/// let alloc = allocator.build(); /// let alloc = allocator.build();
/// ``` /// ```
#[derive(Debug)]
pub struct GenesisAllocator<'a> { pub struct GenesisAllocator<'a> {
/// The genesis alloc to be built. /// The genesis alloc to be built.
alloc: HashMap<Address, GenesisAccount>, alloc: HashMap<Address, GenesisAccount>,
/// The rng to use for generating key pairs. /// The rng to use for generating key pairs.
rng: Box<dyn RngDebug + 'a>, rng: Box<dyn RngCore + 'a>,
} }
impl<'a> GenesisAllocator<'a> { impl<'a> GenesisAllocator<'a> {
/// Initialize a new alloc builder with the provided rng. /// Initialize a new alloc builder with the provided rng.
pub fn new_with_rng<R>(rng: &'a mut R) -> Self pub fn new_with_rng<R>(rng: &'a mut R) -> Self
where where
R: RngCore + std::fmt::Debug, R: RngCore,
{ {
Self { alloc: HashMap::default(), rng: Box::new(rng) } Self { alloc: HashMap::default(), rng: Box::new(rng) }
} }
@ -197,8 +199,8 @@ impl Default for GenesisAllocator<'_> {
} }
} }
/// Helper trait that encapsulates [RngCore], and [Debug](std::fmt::Debug) to get around rules impl fmt::Debug for GenesisAllocator<'_> {
/// for auto traits (Opt-in built-in traits). fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
trait RngDebug: RngCore + std::fmt::Debug {} f.debug_struct("GenesisAllocator").field("alloc", &self.alloc).finish_non_exhaustive()
}
impl<T> RngDebug for T where T: RngCore + std::fmt::Debug {} }

View File

@ -6,6 +6,7 @@
issue_tracker_base_url = "https://github.com/paradigmxyz/reth/issues/" issue_tracker_base_url = "https://github.com/paradigmxyz/reth/issues/"
)] )]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
pub mod genesis_allocator; pub mod genesis_allocator;