Skip to content

Commit

Permalink
Simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
fmoletta committed Sep 20, 2024
1 parent 6b58f27 commit 48d1ca6
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions crates/core/types/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,17 +190,14 @@ impl Genesis {
}

pub fn compute_state_root(&self) -> H256 {
let to_trie_input =
|(address, account): (&Address, &GenesisAccount)| -> (Vec<u8>, Vec<u8>) {
(
Keccak256::new_with_prefix(address.to_fixed_bytes())
.finalize()
.to_vec(),
AccountState::from(account).encode_to_vec(),
)
};

let iter = self.alloc.iter().map(to_trie_input);
let iter = self.alloc.iter().map(|(addr, account)| {
(
Keccak256::new_with_prefix(addr.to_fixed_bytes())
.finalize()
.to_vec(),
AccountState::from(account).encode_to_vec(),
)
});
Trie::compute_hash_from_unsorted_iter(iter)
}
}
Expand Down

0 comments on commit 48d1ca6

Please sign in to comment.