diff --git a/cmd/rlpdump/main.go b/cmd/rlpdump/main.go index 8567dcff83..528ccc6bd6 100644 --- a/cmd/rlpdump/main.go +++ b/cmd/rlpdump/main.go @@ -78,7 +78,7 @@ func main() { os.Exit(2) } - s := rlp.NewStream(r) + s := rlp.NewStream(r, 0) for { if err := dump(s, 0); err != nil { if err != io.EOF { diff --git a/cmd/utils/cmd.go b/cmd/utils/cmd.go index 7286f5c5e4..64faf6ad1b 100644 --- a/cmd/utils/cmd.go +++ b/cmd/utils/cmd.go @@ -154,7 +154,7 @@ func ImportChain(chainmgr *core.ChainManager, fn string) error { defer fh.Close() chainmgr.Reset() - stream := rlp.NewStream(fh) + stream := rlp.NewStream(fh, 0) var i, n int batchSize := 2500 diff --git a/eth/protocol.go b/eth/protocol.go index 1a19307dba..6b566f31b8 100644 --- a/eth/protocol.go +++ b/eth/protocol.go @@ -210,7 +210,7 @@ func (self *ethProtocol) handle() error { return p2p.Send(self.rw, BlockHashesMsg, hashes) case BlockHashesMsg: - msgStream := rlp.NewStream(msg.Payload) + msgStream := rlp.NewStream(msg.Payload, uint64(msg.Size)) if _, err := msgStream.List(); err != nil { return err } @@ -231,7 +231,7 @@ func (self *ethProtocol) handle() error { self.blockPool.AddBlockHashes(iter, self.id) case GetBlocksMsg: - msgStream := rlp.NewStream(msg.Payload) + msgStream := rlp.NewStream(msg.Payload, uint64(msg.Size)) if _, err := msgStream.List(); err != nil { return err } @@ -259,7 +259,7 @@ func (self *ethProtocol) handle() error { return p2p.Send(self.rw, BlocksMsg, blocks) case BlocksMsg: - msgStream := rlp.NewStream(msg.Payload) + msgStream := rlp.NewStream(msg.Payload, uint64(msg.Size)) if _, err := msgStream.List(); err != nil { return err } diff --git a/p2p/message.go b/p2p/message.go index b42acbe3cf..be6405d6f0 100644 --- a/p2p/message.go +++ b/p2p/message.go @@ -32,7 +32,8 @@ type Msg struct { // // For the decoding rules, please see package rlp. func (msg Msg) Decode(val interface{}) error { - if err := rlp.Decode(msg.Payload, val); err != nil { + s := rlp.NewStream(msg.Payload, uint64(msg.Size)) + if err := s.Decode(val); err != nil { return newPeerError(errInvalidMsg, "(code %x) (size %d) %v", msg.Code, msg.Size, err) } return nil diff --git a/whisper/peer.go b/whisper/peer.go index e4301f37c3..28abf42605 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) }