From 2863343f039bfcb3817363d816495c8f9b838d2f Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Mon, 22 Jun 2020 15:51:32 +0300 Subject: [PATCH] consensus: use a method function for NewPayload() --- pkg/consensus/consensus.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/consensus/consensus.go b/pkg/consensus/consensus.go index a53e0257d..4a848e10b 100644 --- a/pkg/consensus/consensus.go +++ b/pkg/consensus/consensus.go @@ -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 {