diff --git a/whisper/whisperv6/doc.go b/whisper/whisperv6/doc.go index a98760b9..06736e55 100644 --- a/whisper/whisperv6/doc.go +++ b/whisper/whisperv6/doc.go @@ -104,6 +104,9 @@ const ( peerSource envelopeSource = iota // p2pSource indicates that envelop was received from a trusted peer. p2pSource + + forwarded = true + inHouse = false ) // EnvelopeMeta keeps metadata of received envelopes. diff --git a/whisper/whisperv6/whisper.go b/whisper/whisperv6/whisper.go index a9e12d4a..8bd991a9 100644 --- a/whisper/whisperv6/whisper.go +++ b/whisper/whisperv6/whisper.go @@ -658,7 +658,7 @@ func (whisper *Whisper) Unsubscribe(id string) error { // Send injects a message into the whisper send queue, to be distributed in the // network in the coming cycles. func (whisper *Whisper) Send(envelope *Envelope) error { - ok, err := whisper.add(envelope) + ok, err := whisper.add(envelope, inHouse) if err != nil { return err } @@ -745,7 +745,7 @@ func (whisper *Whisper) runMessageLoop(p *Peer, rw p2p.MsgReadWriter) error { trouble := false for _, env := range envelopes { whisper.traceEnvelope(env, !whisper.isEnvelopeCached(env.Hash()), peerSource, p) - cached, err := whisper.add(env) + cached, err := whisper.add(env, forwarded) if err != nil { trouble = true log.Error("bad envelope received, peer will be disconnected", "peer", p.peer.ID(), "err", err) @@ -819,7 +819,7 @@ func (whisper *Whisper) runMessageLoop(p *Peer, rw p2p.MsgReadWriter) error { // add inserts a new envelope into the message pool to be distributed within the // whisper network. It also inserts the envelope into the expiration pool at the // appropriate time-stamp. In case of error, connection should be dropped. -func (whisper *Whisper) add(envelope *Envelope) (bool, error) { +func (whisper *Whisper) add(envelope *Envelope, isForwarded bool) (bool, error) { now := uint32(time.Now().Unix()) sent := envelope.Expiry - envelope.TTL @@ -852,7 +852,7 @@ func (whisper *Whisper) add(envelope *Envelope) (bool, error) { } } - if !bloomFilterMatch(whisper.BloomFilter(), envelope.Bloom()) { + if isForwarded && !bloomFilterMatch(whisper.BloomFilter(), envelope.Bloom()) { // maybe the value was recently changed, and the peers did not adjust yet. // in this case the previous value is retrieved by BloomFilterTolerance() // for a short period of peer synchronization.