isForwarded constants introduced
This commit is contained in:
parent
b4c1cd7212
commit
e2e2af73d7
|
@ -1,5 +1,19 @@
|
|||
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..ee82ac6d 100644
|
||||
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 {
|
||||
|
@ -7,7 +21,7 @@ index a9e12d4a..ee82ac6d 100644
|
|||
// network in the coming cycles.
|
||||
func (whisper *Whisper) Send(envelope *Envelope) error {
|
||||
- ok, err := whisper.add(envelope)
|
||||
+ ok, err := whisper.add(envelope, false)
|
||||
+ ok, err := whisper.add(envelope, inHouse)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -16,7 +30,7 @@ index a9e12d4a..ee82ac6d 100644
|
|||
for _, env := range envelopes {
|
||||
whisper.traceEnvelope(env, !whisper.isEnvelopeCached(env.Hash()), peerSource, p)
|
||||
- cached, err := whisper.add(env)
|
||||
+ cached, err := whisper.add(env, true)
|
||||
+ 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)
|
||||
|
@ -28,11 +42,11 @@ index a9e12d4a..ee82ac6d 100644
|
|||
+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.
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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, false)
|
||||
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, true)
|
||||
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)
|
||||
|
|
Loading…
Reference in New Issue