Skip to content

Commit

Permalink
Introduce StartRound function to the backend
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan-Ethernal committed Apr 23, 2024
1 parent 5a229e5 commit 87b5838
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions core/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ type Backend interface {
Verifier
ValidatorBackend

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

// BuildProposal builds a new proposal for the given view (height and round)
BuildProposal(view *proto.View) []byte

Expand Down
2 changes: 2 additions & 0 deletions core/ibft.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,8 @@ func (i *IBFT) RunSequence(ctx context.Context, h uint64) {
for {
view := i.state.getView()

i.backend.StartRound(view)

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

currentRound := view.Round
Expand Down
8 changes: 8 additions & 0 deletions core/mock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +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)

var _ Backend = &mockBackend{}

Expand All @@ -83,6 +84,7 @@ type mockBackend struct {
insertProposalFn insertProposalDelegate
idFn idDelegate
getVotingPowerFn getVotingPowerDelegate
startRoundFn startRoundDelegate
}

func (m mockBackend) ID() []byte {
Expand Down Expand Up @@ -202,6 +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) {
if m.startRoundFn != nil {
m.startRoundFn(view)
}
}

// Define delegation methods
type multicastFnDelegate func(*proto.Message)

Expand Down

0 comments on commit 87b5838

Please sign in to comment.