Skip to content

Commit

Permalink
Merge pull request #37 from BoostryJP/fix/#35
Browse files Browse the repository at this point in the history
consensus/istanbul: Put synchronous back when block has to be propose immediately
  • Loading branch information
YoshihitoAso committed Mar 2, 2023
2 parents 5344ded + 2bd7560 commit 6996557
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions consensus/istanbul/qbft/core/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,30 @@ func (c *core) handleRequest(request *Request) error {
if ok && len(block.Transactions()) == 0 { // if empty block
if config.EmptyBlockPeriod > config.BlockPeriod {
log.Info("EmptyBlockPeriod detected adding delay to request", "EmptyBlockPeriod", config.EmptyBlockPeriod, "BlockTime", block.Time())
// Because the seal has an additional delay on the block period you need to subtract it from the delay
delay = time.Duration(config.EmptyBlockPeriod-config.BlockPeriod) * time.Second
header := block.Header()
// Because the block period has already been added to the time we subtract it here
header.Time = header.Time + config.EmptyBlockPeriod - config.BlockPeriod
request.Proposal = block.WithSeal(header)
}
}

c.newRoundTimer = time.AfterFunc(delay, func() {
c.newRoundTimer = nil

if delay > 0 {
c.newRoundTimer = time.AfterFunc(delay, func() {
c.newRoundTimer = nil
// Start ROUND-CHANGE timer
c.newRoundChangeTimer()

// Send PRE-PREPARE message to other validators
c.sendPreprepareMsg(request)
})
} else {
// Start ROUND-CHANGE timer
c.newRoundChangeTimer()

// Send PRE-PREPARE message to other validators
c.sendPreprepareMsg(request)
})
}
}
}

Expand Down

0 comments on commit 6996557

Please sign in to comment.