Skip to content

Commit

Permalink
miner: define logic LastBlockMiningTime
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanBSC committed Aug 2, 2024
1 parent 44686b1 commit 760bd68
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -1332,6 +1332,20 @@ LOOP:
workList = append(workList, work)

delay := w.engine.Delay(w.chain, work.header, &w.config.DelayLeftOver)
if w.config.MB.LastBlockMiningTime > w.chainConfig.Parlia.Period*1000/2 {
if p, ok := w.engine.(*parlia.Parlia); ok {
service := p.APIs(w.chain)[0].Service
latestBlockNumber := rpc.LatestBlockNumber
currentTurnLength, err := service.(*parlia.API).GetTurnLength(&latestBlockNumber)
if err == nil && (work.header.Number.Uint64()+1)%uint64(currentTurnLength) == 0 {
*delay += time.Duration((w.config.MB.LastBlockMiningTime - w.chainConfig.Parlia.Period*1000/2) * uint64(time.Millisecond))
timeLeft := time.Until(time.Unix(int64(work.header.Time), 0))
if *delay > timeLeft {
*delay = timeLeft
}
}
}
}
if delay == nil {
log.Warn("commitWork delay is nil, something is wrong")
stopTimer = nil
Expand Down

0 comments on commit 760bd68

Please sign in to comment.