consensus: fix error checking in decoders

Spotted by errcheck.
This commit is contained in:
Roman Khimov 2021-05-12 20:14:52 +03:00
parent 99108c620f
commit 4caff35e73
2 changed files with 9 additions and 10 deletions

View file

@ -373,7 +373,12 @@ func (s *service) payloadFromExtensible(ep *npayload.Extensible) *Payload {
func (s *service) OnPayload(cp *npayload.Extensible) {
log := s.log.With(zap.Stringer("hash", cp.Hash()))
p := s.payloadFromExtensible(cp)
p.decodeData()
// decode payload data into message
if err := p.decodeData(); err != nil {
log.Info("can't decode payload data", zap.Error(err))
return
}
if !s.validatePayload(p) {
log.Info("can't validate payload")
return
@ -384,14 +389,6 @@ func (s *service) OnPayload(cp *npayload.Extensible) {
return
}
// decode payload data into message
if p.message.payload == nil {
if err := p.decodeData(); err != nil {
log.Info("can't decode payload data")
return
}
}
s.messages <- *p
}

View file

@ -151,7 +151,9 @@ func (p *Payload) Hash() util.Uint256 {
// DecodeBinary implements io.Serializable interface.
func (p *Payload) DecodeBinary(r *io.BinReader) {
p.Extensible.DecodeBinary(r)
p.decodeData()
if r.Err == nil {
r.Err = p.decodeData()
}
}
// EncodeBinary implements io.Serializable interface.