diff options
author | Felix Lange <fjl@twurst.com> | 2015-03-21 07:49:58 +0800 |
---|---|---|
committer | Felix Lange <fjl@twurst.com> | 2015-03-21 07:49:58 +0800 |
commit | 483d43a15af11a9c456e4d9df0520441b947cd35 (patch) | |
tree | ae60e1843e90a9f1a4f7ee6e5d702437a88d5fa2 /whisper/peer.go | |
parent | a829a5658723ff3681f14650818ef050cb0a7fa8 (diff) | |
download | go-tangerine-483d43a15af11a9c456e4d9df0520441b947cd35.tar go-tangerine-483d43a15af11a9c456e4d9df0520441b947cd35.tar.gz go-tangerine-483d43a15af11a9c456e4d9df0520441b947cd35.tar.bz2 go-tangerine-483d43a15af11a9c456e4d9df0520441b947cd35.tar.lz go-tangerine-483d43a15af11a9c456e4d9df0520441b947cd35.tar.xz go-tangerine-483d43a15af11a9c456e4d9df0520441b947cd35.tar.zst go-tangerine-483d43a15af11a9c456e4d9df0520441b947cd35.zip |
whisper: use package rlp
Diffstat (limited to 'whisper/peer.go')
-rw-r--r-- | whisper/peer.go | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/whisper/peer.go b/whisper/peer.go index ee5bffd0b..338166c25 100644 --- a/whisper/peer.go +++ b/whisper/peer.go @@ -10,7 +10,7 @@ import ( ) const ( - protocolVersion = 0x02 + protocolVersion uint64 = 0x02 ) type peer struct { @@ -66,21 +66,18 @@ out: } func (self *peer) broadcast(envelopes []*Envelope) error { - envs := make([]interface{}, len(envelopes)) - i := 0 - for _, envelope := range envelopes { - if !self.known.Has(envelope.Hash()) { - envs[i] = envelope - self.known.Add(envelope.Hash()) - i++ + envs := make([]*Envelope, 0, len(envelopes)) + for _, env := range envelopes { + if !self.known.Has(env.Hash()) { + envs = append(envs, env) + self.known.Add(env.Hash()) } } - - if i > 0 { - if err := p2p.Send(self.ws, envelopesMsg, envs[:i]); err != nil { + if len(envs) > 0 { + if err := p2p.Send(self.ws, envelopesMsg, envs); err != nil { return err } - self.peer.DebugDetailln("broadcasted", i, "message(s)") + self.peer.DebugDetailln("broadcasted", len(envs), "message(s)") } return nil } |