Provide `View` instance to `BuildProposal` (#62)

Provide view to BuildProposal
parallel-message-handling v0.3.0
Stefan Negovanović 2 years ago committed by GitHub
parent d3776f4434
commit 9a2958bc32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      core/backend.go
  2. 12
      core/ibft.go
  3. 4
      core/mock_test.go

@ -25,7 +25,7 @@ type MessageConstructor interface {
BuildCommitMessage(proposalHash []byte, view *proto.View) *proto.Message
// BuildRoundChangeMessage builds a ROUND_CHANGE message based on the passed in view,
// latest prepared proposed block, and latest prepared certificate
// latest prepared proposal, and latest prepared certificate
BuildRoundChangeMessage(
proposal *proto.Proposal,
certificate *proto.PreparedCertificate,
@ -35,7 +35,7 @@ type MessageConstructor interface {
// Verifier defines the verifier interface
type Verifier interface {
// IsValidProposal if the proposal is valid
// IsValidProposal checks if the proposal is valid
IsValidProposal(rawProposal []byte) bool
// IsValidValidator checks if a signature in message is signed by sender
@ -61,8 +61,8 @@ type Backend interface {
MessageConstructor
Verifier
// BuildProposal builds a new proposal for the height
BuildProposal(height uint64) []byte
// BuildProposal builds a new proposal for the given view (height and round)
BuildProposal(view *proto.View) []byte
// InsertProposal inserts a proposal with the specified committed seals
// the reason why we are including round here is because a single committedSeal

@ -975,7 +975,11 @@ func (i *IBFT) buildProposal(ctx context.Context, view *proto.View) *proto.Messa
)
if round == 0 {
rawProposal := i.backend.BuildProposal(height)
rawProposal := i.backend.BuildProposal(
&proto.View{
Height: height,
Round: round,
})
return i.backend.BuildPrePrepareMessage(
rawProposal,
@ -1026,7 +1030,11 @@ func (i *IBFT) buildProposal(ctx context.Context, view *proto.View) *proto.Messa
if previousProposal == nil {
// build new proposal
proposal := i.backend.BuildProposal(height)
proposal := i.backend.BuildProposal(
&proto.View{
Height: height,
Round: round,
})
return i.backend.BuildPrePrepareMessage(
proposal,

@ -120,9 +120,9 @@ func (m mockBackend) IsProposer(id []byte, sequence, round uint64) bool {
return false
}
func (m mockBackend) BuildProposal(height uint64) []byte {
func (m mockBackend) BuildProposal(view *proto.View) []byte {
if m.buildProposalFn != nil {
return m.buildProposalFn(height)
return m.buildProposalFn(view.Height)
}
return nil

Loading…
Cancel
Save