aboutsummaryrefslogtreecommitdiffstats
path: root/whisper/whisperv6/whisper.go
diff options
context:
space:
mode:
Diffstat (limited to 'whisper/whisperv6/whisper.go')
-rw-r--r--whisper/whisperv6/whisper.go28
1 files changed, 18 insertions, 10 deletions
diff --git a/whisper/whisperv6/whisper.go b/whisper/whisperv6/whisper.go
index d09baab3f..2cc1e64f5 100644
--- a/whisper/whisperv6/whisper.go
+++ b/whisper/whisperv6/whisper.go
@@ -515,18 +515,26 @@ func (wh *Whisper) runMessageLoop(p *Peer, rw p2p.MsgReadWriter) error {
log.Warn("unxepected status message received", "peer", p.peer.ID())
case messagesCode:
// decode the contained envelopes
- var envelope Envelope
- if err := packet.Decode(&envelope); err != nil {
- log.Warn("failed to decode envelope, peer will be disconnected", "peer", p.peer.ID(), "err", err)
- return errors.New("invalid envelope")
+ var envelopes []*Envelope
+ if err := packet.Decode(&envelopes); err != nil {
+ log.Warn("failed to decode envelopes, peer will be disconnected", "peer", p.peer.ID(), "err", err)
+ return errors.New("invalid envelopes")
}
- cached, err := wh.add(&envelope)
- if err != nil {
- log.Warn("bad envelope received, peer will be disconnected", "peer", p.peer.ID(), "err", err)
- return errors.New("invalid envelope")
+
+ trouble := false
+ for _, env := range envelopes {
+ cached, err := wh.add(env)
+ if err != nil {
+ trouble = true
+ log.Error("bad envelope received, peer will be disconnected", "peer", p.peer.ID(), "err", err)
+ }
+ if cached {
+ p.mark(env)
+ }
}
- if cached {
- p.mark(&envelope)
+
+ if trouble {
+ return errors.New("invalid envelope")
}
case p2pCode:
// peer-to-peer message, sent directly to peer bypassing PoW checks, etc.