mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-17 19:47:19 +00:00
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
|
// 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 {
|
||||||
|
switch m.Command {
|
||||||
|
case CMDFilterClear, CMDGetAddr, CMDMempool:
|
||||||
m.Payload = payload.NewNullPayload()
|
m.Payload = payload.NewNullPayload()
|
||||||
|
default:
|
||||||
|
return errors.New("unexpected empty payload")
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if l > PayloadMaxSize {
|
if l > PayloadMaxSize {
|
||||||
|
|
|
@ -12,12 +12,12 @@ type NullPayload struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewNullPayload returns zero-sized stub payload.
|
// NewNullPayload returns zero-sized stub payload.
|
||||||
func NewNullPayload() *NullPayload {
|
func NewNullPayload() NullPayload {
|
||||||
return &NullPayload{}
|
return NullPayload{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DecodeBinary implements Serializable interface.
|
// DecodeBinary implements Serializable interface.
|
||||||
func (p *NullPayload) DecodeBinary(r *io.BinReader) {}
|
func (p NullPayload) DecodeBinary(r *io.BinReader) {}
|
||||||
|
|
||||||
// EncodeBinary implements Serializable interface.
|
// EncodeBinary implements Serializable interface.
|
||||||
func (p *NullPayload) EncodeBinary(w *io.BinWriter) {}
|
func (p NullPayload) EncodeBinary(w *io.BinWriter) {}
|
||||||
|
|
Loading…
Reference in a new issue