Skip to content

Commit

Permalink
Consensus: let epoch_duration_target affect epoch length
Browse files Browse the repository at this point in the history
Signed-off-by: Eval EXEC <[email protected]>
  • Loading branch information
eval-exec committed Aug 11, 2023
1 parent 290eeed commit 27af3cd
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions spec/src/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,13 @@ impl Consensus {
let remainder_reward =
Capacity::shannons(primary_epoch_reward % epoch.length());

let mut next_epoch_length = epoch.length();
let epoch_length_from_param =
cmp::max(self.epoch_duration_target() / MIN_BLOCK_INTERVAL, 1);
if next_epoch_length != epoch_length_from_param {
next_epoch_length = self.epoch_duration_target() / MIN_BLOCK_INTERVAL;
}

let dummy_epoch_ext = epoch
.clone()
.into_builder()
Expand All @@ -812,6 +819,7 @@ impl Consensus {
.number(epoch.number() + 1)
.last_block_hash_in_previous_epoch(header.hash())
.start_number(header.number() + 1)
.length(next_epoch_length.into())
.build();
NextBlockEpoch::HeadBlock(dummy_epoch_ext)
} else {
Expand Down

0 comments on commit 27af3cd

Please sign in to comment.