aboutsummaryrefslogtreecommitdiffstats
path: root/whisper/whisperv5/peer.go
diff options
context:
space:
mode:
authorgluk256 <gluk256@users.noreply.github.com>2017-04-27 03:05:48 +0800
committerFelix Lange <fjl@users.noreply.github.com>2017-04-27 03:05:48 +0800
commit95f0bd0acf301bf8415747c4ff050e8a4dfdc864 (patch)
tree13edad970fb30a8e12151b2ec1a443b0ad970d2b /whisper/whisperv5/peer.go
parent8dce4c283dda3a8e10aa30dadab05a8c0dd9e19d (diff)
downloaddexon-95f0bd0acf301bf8415747c4ff050e8a4dfdc864.tar
dexon-95f0bd0acf301bf8415747c4ff050e8a4dfdc864.tar.gz
dexon-95f0bd0acf301bf8415747c4ff050e8a4dfdc864.tar.bz2
dexon-95f0bd0acf301bf8415747c4ff050e8a4dfdc864.tar.lz
dexon-95f0bd0acf301bf8415747c4ff050e8a4dfdc864.tar.xz
dexon-95f0bd0acf301bf8415747c4ff050e8a4dfdc864.tar.zst
dexon-95f0bd0acf301bf8415747c4ff050e8a4dfdc864.zip
whisper: message format refactoring (#14335)
* whisper: salt removed from AES encryption * whisper: padding format updated * whisper: padding test added * whisper: padding refactored, tests fixed * whisper: padding test updated * whisper: wnode bugfix * whisper: send/receive protocol updated * whisper: minor update * whisper: bugfix in test * whisper: updated parameter names and comments * whisper: functions renamed * whisper: minor refactoring
Diffstat (limited to 'whisper/whisperv5/peer.go')
-rw-r--r--whisper/whisperv5/peer.go21
1 files changed, 10 insertions, 11 deletions
diff --git a/whisper/whisperv5/peer.go b/whisper/whisperv5/peer.go
index 184c4ebf8..179c93179 100644
--- a/whisper/whisperv5/peer.go
+++ b/whisper/whisperv5/peer.go
@@ -149,23 +149,22 @@ func (peer *Peer) expire() {
// broadcast iterates over the collection of envelopes and transmits yet unknown
// ones over the network.
func (p *Peer) broadcast() error {
- // Fetch the envelopes and collect the unknown ones
+ var cnt int
envelopes := p.host.Envelopes()
- transmit := make([]*Envelope, 0, len(envelopes))
for _, envelope := range envelopes {
if !p.marked(envelope) {
- transmit = append(transmit, envelope)
- p.mark(envelope)
+ err := p2p.Send(p.ws, messagesCode, envelope)
+ if err != nil {
+ return err
+ } else {
+ p.mark(envelope)
+ cnt++
+ }
}
}
- if len(transmit) == 0 {
- return nil
- }
- // Transmit the unknown batch (potentially empty)
- if err := p2p.Send(p.ws, messagesCode, transmit); err != nil {
- return err
+ if cnt > 0 {
+ log.Trace("broadcast", "num. messages", cnt)
}
- log.Trace("broadcast", "num. messages", len(transmit))
return nil
}