patch sending message without subscription applied

This commit is contained in:
Evgeny Danienko 2018-03-26 19:30:31 +03:00
parent aaf2b41e2e
commit de0c03ca4e
No known key found for this signature in database
GPG Key ID: BC8C34D8B45BECBF
4 changed files with 6 additions and 1 deletions

View File

@ -264,6 +264,7 @@ func (api *PublicWhisperAPI) Post(ctx context.Context, req NewMessage) (bool, er
WorkTime: req.PowTime,
PoW: req.PowTarget,
Topic: req.Topic,
self: true,
}
// Set key that is used to sign the message

View File

@ -47,6 +47,7 @@ type Envelope struct {
// the following variables should not be accessed directly, use the corresponding function instead: Hash(), Bloom()
hash common.Hash // Cached hash of the envelope to avoid rehashing every time.
bloom []byte
self bool
}
// size returns the size of envelope as it is sent (i.e. public fields only)

View File

@ -46,6 +46,8 @@ type MessageParams struct {
PoW float64
Payload []byte
Padding []byte
self bool
}
// SentMessage represents an end-user data packet to transmit through the
@ -258,6 +260,7 @@ func (msg *sentMessage) Wrap(options *MessageParams) (envelope *Envelope, err er
if err = envelope.Seal(options); err != nil {
return nil, err
}
envelope.self = options.self
return envelope, nil
}

View File

@ -852,7 +852,7 @@ func (whisper *Whisper) add(envelope *Envelope) (bool, error) {
}
}
if !bloomFilterMatch(whisper.BloomFilter(), envelope.Bloom()) {
if !envelope.self && !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.