Skip to content

Commit

Permalink
dbft: simplify PreBlock constructor
Browse files Browse the repository at this point in the history
Move hasAllTransactions check from PreBlock constructor to onPreCommit
callback. The rest of CreatePreBlock usages already have this check.

Signed-off-by: Anna Shaleva <[email protected]>
  • Loading branch information
AnnaShaleva committed Sep 3, 2024
1 parent a70ec44 commit a6c5026
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 0 additions & 3 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
3 changes: 3 additions & 0 deletions dbft.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Check warning on line 548 in dbft.go

View check run for this annotation

Codecov / codecov/patch

dbft.go#L548

Added line #L548 was not covered by tests
}
preBlock := d.CreatePreBlock()
if preBlock != nil {
pub := d.Validators[msg.ValidatorIndex()]
Expand Down

0 comments on commit a6c5026

Please sign in to comment.