Skip to content

Commit

Permalink
Add error to the StartRound signature
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan-Ethernal committed Apr 24, 2024
1 parent 87b5838 commit ffd0b6c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion core/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ type Backend interface {
ValidatorBackend

// StartRound notifies the backend implementation whenever new round is about to start
StartRound(view *proto.View)
StartRound(view *proto.View) error

// BuildProposal builds a new proposal for the given view (height and round)
BuildProposal(view *proto.View) []byte
Expand Down
6 changes: 5 additions & 1 deletion core/ibft.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,11 @@ func (i *IBFT) RunSequence(ctx context.Context, h uint64) {
for {
view := i.state.getView()

i.backend.StartRound(view)
if err := i.backend.StartRound(view); err != nil {
i.log.Error("failed to start round on backend, aborting sequence...", "round", view.Round, "err", err)

return
}

i.log.Info("round started", "round", view.Round)

Expand Down
8 changes: 5 additions & 3 deletions core/mock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ type buildRoundChangeMessageDelegate func(
type insertProposalDelegate func(*proto.Proposal, []*messages.CommittedSeal)
type idDelegate func() []byte
type getVotingPowerDelegate func(uint64) (map[string]*big.Int, error)
type startRoundDelegate func(*proto.View)
type startRoundDelegate func(*proto.View) error

var _ Backend = &mockBackend{}

Expand Down Expand Up @@ -204,10 +204,12 @@ func (m mockBackend) GetVotingPowers(height uint64) (map[string]*big.Int, error)
return map[string]*big.Int{}, nil
}

func (m mockBackend) StartRound(view *proto.View) {
func (m mockBackend) StartRound(view *proto.View) error {
if m.startRoundFn != nil {
m.startRoundFn(view)
return m.startRoundFn(view)
}

return nil
}

// Define delegation methods
Expand Down

0 comments on commit ffd0b6c

Please sign in to comment.