forked from TrueCloudLab/neoneo-go
Merge pull request #1072 from nspcc-dev/fix/payload
Allow NullPayload only for CMDGetAddr
This commit is contained in:
commit
75cc109837
2 changed files with 10 additions and 5 deletions
|
@ -106,7 +106,12 @@ func (m *Message) Decode(br *io.BinReader) error {
|
|||
// check the length first in order not to allocate memory
|
||||
// for an empty compressed payload
|
||||
if l == 0 {
|
||||
m.Payload = payload.NewNullPayload()
|
||||
switch m.Command {
|
||||
case CMDFilterClear, CMDGetAddr, CMDMempool:
|
||||
m.Payload = payload.NewNullPayload()
|
||||
default:
|
||||
return errors.New("unexpected empty payload")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
if l > PayloadMaxSize {
|
||||
|
|
|
@ -12,12 +12,12 @@ type NullPayload struct {
|
|||
}
|
||||
|
||||
// NewNullPayload returns zero-sized stub payload.
|
||||
func NewNullPayload() *NullPayload {
|
||||
return &NullPayload{}
|
||||
func NewNullPayload() NullPayload {
|
||||
return NullPayload{}
|
||||
}
|
||||
|
||||
// DecodeBinary implements Serializable interface.
|
||||
func (p *NullPayload) DecodeBinary(r *io.BinReader) {}
|
||||
func (p NullPayload) DecodeBinary(r *io.BinReader) {}
|
||||
|
||||
// EncodeBinary implements Serializable interface.
|
||||
func (p *NullPayload) EncodeBinary(w *io.BinWriter) {}
|
||||
func (p NullPayload) EncodeBinary(w *io.BinWriter) {}
|
||||
|
|
Loading…
Reference in a new issue