-
Notifications
You must be signed in to change notification settings - Fork 20.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
whisper: messge bundling #15666
whisper: messge bundling #15666
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -515,18 +515,20 @@ 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") | ||
} | ||
if cached { | ||
p.mark(&envelope) | ||
for _, env := range envelopes { | ||
cached, err := wh.add(env) | ||
if err != nil { | ||
log.Warn("bad envelope received, peer will be disconnected", "peer", p.peer.ID(), "err", err) | ||
return errors.New("invalid envelope") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wait, does that mean that if 1 of the envelopes has a bad format, then you will stop decoding all the envelopes? That sounds very harsh, and a potential threat to the network: all an attacker has to do to disrupt communications is to start sending invalid envelopes. They would get disconnected, sure, but if they hold a significant portion of the network they can still use this as a kill switch. |
||
} | ||
if cached { | ||
p.mark(env) | ||
} | ||
} | ||
case p2pCode: | ||
// peer-to-peer message, sent directly to peer bypassing PoW checks, etc. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
transmit the (potentially empty) batch of unknown envelopes