From a6c502619bad292d4d06b125b2d3286aa85143b7 Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Tue, 3 Sep 2024 13:35:58 +0300 Subject: [PATCH] dbft: simplify PreBlock constructor Move hasAllTransactions check from PreBlock constructor to onPreCommit callback. The rest of CreatePreBlock usages already have this check. Signed-off-by: Anna Shaleva --- context.go | 3 --- dbft.go | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/context.go b/context.go index c98b688d..c580349c 100644 --- a/context.go +++ b/context.go @@ -344,9 +344,6 @@ func (c *Context[H]) CreatePreBlock() PreBlock[H] { if c.preBlock = c.MakePreHeader(); c.preBlock == nil { return nil } - if !c.hasAllTransactions() { - return nil - } txx := make([]Transaction[H], len(c.TransactionHashes)) diff --git a/dbft.go b/dbft.go index 4cb380d8..2ce20dc8 100644 --- a/dbft.go +++ b/dbft.go @@ -544,6 +544,9 @@ func (d *DBFT[H]) onPreCommit(msg ConsensusPayload[H]) { d.Logger.Info("received PreCommit", zap.Uint("validator", uint(msg.ValidatorIndex()))) d.extendTimer(4) + if !d.hasAllTransactions() { + return + } preBlock := d.CreatePreBlock() if preBlock != nil { pub := d.Validators[msg.ValidatorIndex()]