Skip to content

Commit

Permalink
consensus/parlia: modify mining time for last block in one turn (#2608)
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanBSC authored Jul 25, 2024
1 parent cabd0f8 commit 3134494
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions consensus/parlia/parlia.go
Original file line number Diff line number Diff line change
Expand Up @@ -1510,14 +1510,8 @@ func (p *Parlia) Delay(chain consensus.ChainReader, header *types.Header, leftOv

// The blocking time should be no more than half of period when snap.TurnLength == 1
timeForMining := time.Duration(p.config.Period) * time.Second / 2
if snap.TurnLength > 1 {
if snap.lastBlockInOneTurn(header.Number.Uint64()) {
// To ensure that the next validator produces and broadcasts blocks in a timely manner,
// set the value of timeForMining to a small amount
timeForMining = 500 * time.Millisecond
} else {
timeForMining = time.Duration(p.config.Period) * time.Second * 2 / 3
}
if !snap.lastBlockInOneTurn(header.Number.Uint64()) {
timeForMining = time.Duration(p.config.Period) * time.Second * 2 / 3
}
if delay > timeForMining {
delay = timeForMining
Expand Down

0 comments on commit 3134494

Please sign in to comment.