aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cmd/rlpdump/main.go2
-rw-r--r--cmd/utils/cmd.go2
-rw-r--r--eth/protocol.go6
-rw-r--r--p2p/message.go3
-rw-r--r--whisper/peer.go2
5 files changed, 8 insertions, 7 deletions
diff --git a/cmd/rlpdump/main.go b/cmd/rlpdump/main.go
index 8567dcff8..528ccc6bd 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 7286f5c5e..64faf6ad1 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 1a19307db..6b566f31b 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 b42acbe3c..be6405d6f 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 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)
}