mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
small refactor for Account implementation (#6143)
This commit is contained in:
@ -29,12 +29,9 @@ impl Account {
|
|||||||
/// After SpuriousDragon empty account is defined as account with nonce == 0 && balance == 0 &&
|
/// After SpuriousDragon empty account is defined as account with nonce == 0 && balance == 0 &&
|
||||||
/// bytecode = None.
|
/// bytecode = None.
|
||||||
pub fn is_empty(&self) -> bool {
|
pub fn is_empty(&self) -> bool {
|
||||||
let is_bytecode_empty = match self.bytecode_hash {
|
self.nonce == 0 &&
|
||||||
None => true,
|
self.balance.is_zero() &&
|
||||||
Some(hash) => hash == KECCAK_EMPTY,
|
self.bytecode_hash.map_or(true, |hash| hash == KECCAK_EMPTY)
|
||||||
};
|
|
||||||
|
|
||||||
self.nonce == 0 && self.balance.is_zero() && is_bytecode_empty
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Converts [GenesisAccount] to [Account] type
|
/// Converts [GenesisAccount] to [Account] type
|
||||||
@ -50,10 +47,7 @@ impl Account {
|
|||||||
/// Returns an account bytecode's hash.
|
/// Returns an account bytecode's hash.
|
||||||
/// In case of no bytecode, returns [`KECCAK_EMPTY`].
|
/// In case of no bytecode, returns [`KECCAK_EMPTY`].
|
||||||
pub fn get_bytecode_hash(&self) -> B256 {
|
pub fn get_bytecode_hash(&self) -> B256 {
|
||||||
match self.bytecode_hash {
|
self.bytecode_hash.unwrap_or(KECCAK_EMPTY)
|
||||||
Some(hash) => hash,
|
|
||||||
None => KECCAK_EMPTY,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user