Skip to content

Commit

Permalink
check: set lastBlockTime in PrepareRequest handler, fix #55
Browse files Browse the repository at this point in the history
It's the earliest point, if a view change happens the timer is reset (because
new view comes with a new set of transactions, potentially picking up ones
received between views).
  • Loading branch information
roman-khimov committed Nov 29, 2021
1 parent 1b03241 commit 288fc24
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 5 additions & 2 deletions check.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ import (
)

func (d *DBFT) checkPrepare() {
if d.lastBlockIndex != d.BlockIndex || d.lastBlockView != d.ViewNumber {
d.lastBlockTime = d.Timer.Now()
d.lastBlockIndex = d.BlockIndex
d.lastBlockView = d.ViewNumber
}
if !d.hasAllTransactions() {
d.Logger.Debug("check prepare: some transactions are missing", zap.Any("hashes", d.MissingTransactions))
return
Expand Down Expand Up @@ -58,8 +63,6 @@ func (d *DBFT) checkCommit() {
return
}

d.lastBlockIndex = d.BlockIndex
d.lastBlockTime = d.Timer.Now()
d.block = d.CreateBlock()
hash := d.block.Hash()

Expand Down
1 change: 1 addition & 0 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ type Context struct {

lastBlockTime time.Time
lastBlockIndex uint32
lastBlockView byte
}

// N returns total number of validators.
Expand Down

0 comments on commit 288fc24

Please sign in to comment.