diff options
Diffstat (limited to 'whisper')
-rw-r--r-- | whisper/envelope.go | 9 | ||||
-rw-r--r-- | whisper/peer.go | 2 |
2 files changed, 6 insertions, 5 deletions
diff --git a/whisper/envelope.go b/whisper/envelope.go index 0a817e26e..07762c300 100644 --- a/whisper/envelope.go +++ b/whisper/envelope.go @@ -109,16 +109,17 @@ func (self *Envelope) Hash() common.Hash { return self.hash } -// rlpenv is an Envelope but is not an rlp.Decoder. -// It is used for decoding because we need to -type rlpenv Envelope - // DecodeRLP decodes an Envelope from an RLP data stream. func (self *Envelope) DecodeRLP(s *rlp.Stream) error { raw, err := s.Raw() if err != nil { return err } + // The decoding of Envelope uses the struct fields but also needs + // to compute the hash of the whole RLP-encoded envelope. This + // type has the same structure as Envelope but is not an + // rlp.Decoder so we can reuse the Envelope struct definition. + type rlpenv Envelope if err := rlp.DecodeBytes(raw, (*rlpenv)(self)); err != nil { return err } diff --git a/whisper/peer.go b/whisper/peer.go index e4301f37c..28abf4260 100644 --- a/whisper/peer.go +++ b/whisper/peer.go @@ -66,7 +66,7 @@ func (self *peer) handshake() error { if packet.Code != statusCode { return fmt.Errorf("peer sent %x before status packet", packet.Code) } - s := rlp.NewStream(packet.Payload) + s := rlp.NewStream(packet.Payload, uint64(packet.Size)) if _, err := s.List(); err != nil { return fmt.Errorf("bad status message: %v", err) } |