mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
dev: with_capacity for HashMap (#7246)
This commit is contained in:
@ -930,11 +930,14 @@ impl<DB: Database, EVM: ExecutorFactory> BlockchainTree<DB, EVM> {
|
||||
if let Some(header) = canonical_header {
|
||||
info!(target: "blockchain_tree", ?block_hash, "Block is already canonical, ignoring.");
|
||||
// TODO: this could be fetched from the chainspec first
|
||||
let td = self.externals.provider_factory.provider()?.header_td(block_hash)?.ok_or(
|
||||
CanonicalError::from(BlockValidationError::MissingTotalDifficulty {
|
||||
hash: *block_hash,
|
||||
}),
|
||||
)?;
|
||||
let td =
|
||||
self.externals.provider_factory.provider()?.header_td(block_hash)?.ok_or_else(
|
||||
|| {
|
||||
CanonicalError::from(BlockValidationError::MissingTotalDifficulty {
|
||||
hash: *block_hash,
|
||||
})
|
||||
},
|
||||
)?;
|
||||
if !self
|
||||
.externals
|
||||
.provider_factory
|
||||
|
||||
@ -100,9 +100,10 @@ pub fn insert_genesis_state<DB: Database>(
|
||||
tx: &<DB as Database>::TXMut,
|
||||
genesis: &reth_primitives::Genesis,
|
||||
) -> ProviderResult<()> {
|
||||
let mut state_init: BundleStateInit = HashMap::new();
|
||||
let mut reverts_init = HashMap::new();
|
||||
let mut contracts: HashMap<B256, Bytecode> = HashMap::new();
|
||||
let capacity = genesis.alloc.len();
|
||||
let mut state_init: BundleStateInit = HashMap::with_capacity(capacity);
|
||||
let mut reverts_init = HashMap::with_capacity(capacity);
|
||||
let mut contracts: HashMap<B256, Bytecode> = HashMap::with_capacity(capacity);
|
||||
|
||||
for (address, account) in &genesis.alloc {
|
||||
let bytecode_hash = if let Some(code) = &account.code {
|
||||
|
||||
Reference in New Issue
Block a user