diff --git a/check.go b/check.go index 4b4b9e15..5a206271 100644 --- a/check.go +++ b/check.go @@ -5,6 +5,13 @@ import ( ) func (d *DBFT[H]) checkPrepare() { + if d.lastBlockIndex != d.BlockIndex || d.lastBlockView != d.ViewNumber { + // Notice that lastBlockTimestamp is left unchanged because + // this must be the value from the last header. + 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 @@ -57,8 +64,6 @@ func (d *DBFT[H]) checkCommit() { return } - d.lastBlockIndex = d.BlockIndex - d.lastBlockTime = d.Timer.Now() d.block = d.CreateBlock() hash := d.block.Hash() diff --git a/context.go b/context.go index 4a7ce73d..7b27075f 100644 --- a/context.go +++ b/context.go @@ -76,6 +76,7 @@ type Context[H Hash] struct { lastBlockTimestamp uint64 // ns-precision timestamp from the last header (used for the next block timestamp calculations). lastBlockTime time.Time // Wall clock time of when the last block was first seen (used for timer adjustments). lastBlockIndex uint32 + lastBlockView byte } // N returns total number of validators.