mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
ForkCondition: some small refactors (#10712)
This commit is contained in:
@ -522,10 +522,11 @@ impl ChainSpec {
|
||||
ForkCondition::Timestamp(timestamp) => {
|
||||
// to satisfy every timestamp ForkCondition, we find the last ForkCondition::Block
|
||||
// if one exists, and include its block_num in the returned Head
|
||||
if let Some(last_block_num) = self.last_block_fork_before_merge_or_timestamp() {
|
||||
return Head { timestamp, number: last_block_num, ..Default::default() }
|
||||
Head {
|
||||
timestamp,
|
||||
number: self.last_block_fork_before_merge_or_timestamp().unwrap_or_default(),
|
||||
..Default::default()
|
||||
}
|
||||
Head { timestamp, ..Default::default() }
|
||||
}
|
||||
ForkCondition::TTD { total_difficulty, .. } => {
|
||||
Head { total_difficulty, ..Default::default() }
|
||||
|
||||
@ -68,7 +68,7 @@ impl ChainHardforks {
|
||||
/// Retrieves [`ForkCondition`] from `fork`. If `fork` is not present, returns
|
||||
/// [`ForkCondition::Never`].
|
||||
pub fn fork<H: Hardfork>(&self, fork: H) -> ForkCondition {
|
||||
self.get(fork).unwrap_or(ForkCondition::Never)
|
||||
self.get(fork).unwrap_or_default()
|
||||
}
|
||||
|
||||
/// Retrieves [`ForkCondition`] from `fork` if it exists, otherwise `None`.
|
||||
|
||||
Reference in New Issue
Block a user