diff --git a/cmd/rlpdump/main.go b/cmd/rlpdump/main.go index 8567dcff83e76aaeff5f35090f2ed28f67774e05..528ccc6bd6ab175507604c6c4c2649f87f6884fb 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 7286f5c5e4fa183a386fbbd89ae9352fbcf9ca64..64faf6ad1bd08f013bd3a3086ab60fe11894cf97 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 1a19307dba85ae21427b5f32ed057027fff7cd8d..6b566f31b80d01cc9c45bd6fc3e81c8ce3d1f68e 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 b42acbe3cf096aa6af7284338b76e274d3f064e4..be6405d6f03a67fa70b3abf04a18ac53e52517fc 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 e4301f37c302d439053f4f918db85637773d77ac..28abf42605b32bf2e799cb867d5f849efcd8132b 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) }