forked from TrueCloudLab/neoneo-go
network: allow NullPayload only for specific commands
CMDFilterClear, CMDGetAddr, CMDMempool all have empty payloads.
This commit is contained in:
parent
025bf9c235
commit
9f42108ef2
1 changed files with 6 additions and 1 deletions
|
@ -106,7 +106,12 @@ func (m *Message) Decode(br *io.BinReader) error {
|
||||||
// check the length first in order not to allocate memory
|
// check the length first in order not to allocate memory
|
||||||
// for an empty compressed payload
|
// for an empty compressed payload
|
||||||
if l == 0 {
|
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
|
return nil
|
||||||
}
|
}
|
||||||
if l > PayloadMaxSize {
|
if l > PayloadMaxSize {
|
||||||
|
|
Loading…
Reference in a new issue