consensus: use a method function for NewPayload()

This commit is contained in:
Evgenii Stratonikov 2020-06-22 15:51:32 +03:00
parent 3a6186af54
commit 2863343f03

View file

@ -138,7 +138,7 @@ func NewService(cfg Config) (Service, error) {
dbft.WithGetValidators(srv.getValidators),
dbft.WithGetConsensusAddress(srv.getConsensusAddress),
dbft.WithNewConsensusPayload(func() payload.ConsensusPayload { p := new(Payload); p.message = &message{}; return p }),
dbft.WithNewConsensusPayload(srv.newPayload),
dbft.WithNewPrepareRequest(srv.newPrepareRequest),
dbft.WithNewPrepareResponse(func() payload.PrepareResponse { return new(prepareResponse) }),
dbft.WithNewChangeView(func() payload.ChangeView { return new(changeView) }),
@ -214,6 +214,12 @@ func (s *service) eventLoop() {
}
}
func (s *service) newPayload() payload.ConsensusPayload {
return &Payload{
message: new(message),
}
}
func (s *service) newPrepareRequest() payload.PrepareRequest {
sr, err := s.Chain.GetStateRoot(s.Chain.BlockHeight())
if err != nil {