diff options
author | Guillaume Ballet <gballet@gmail.com> | 2018-03-02 03:27:20 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-02 03:27:20 +0800 |
commit | a76e46e3d7cb77bfcbc95d92df9f4b6ccdd742f2 (patch) | |
tree | aa033434cf54c7194363a8a0bc64cac66682db2a /whisper/whisperv6/peer.go | |
parent | 3ca3fffdf01b94244ef6c2d93ed38a30da9fcb0a (diff) | |
parent | ee75a90ab41fd9a2e5676a2371e529ac2908befa (diff) | |
download | dexon-a76e46e3d7cb77bfcbc95d92df9f4b6ccdd742f2.tar dexon-a76e46e3d7cb77bfcbc95d92df9f4b6ccdd742f2.tar.gz dexon-a76e46e3d7cb77bfcbc95d92df9f4b6ccdd742f2.tar.bz2 dexon-a76e46e3d7cb77bfcbc95d92df9f4b6ccdd742f2.tar.lz dexon-a76e46e3d7cb77bfcbc95d92df9f4b6ccdd742f2.tar.xz dexon-a76e46e3d7cb77bfcbc95d92df9f4b6ccdd742f2.tar.zst dexon-a76e46e3d7cb77bfcbc95d92df9f4b6ccdd742f2.zip |
Merge pull request #16223 from gluk256/300-msg-serialiation
whisper: topics replaced by bloom filters in mailserver communication
Diffstat (limited to 'whisper/whisperv6/peer.go')
-rw-r--r-- | whisper/whisperv6/peer.go | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/whisper/whisperv6/peer.go b/whisper/whisperv6/peer.go index 6d75290fd..2bf1c905b 100644 --- a/whisper/whisperv6/peer.go +++ b/whisper/whisperv6/peer.go @@ -56,7 +56,7 @@ func newPeer(host *Whisper, remote *p2p.Peer, rw p2p.MsgReadWriter) *Peer { powRequirement: 0.0, known: set.New(), quit: make(chan struct{}), - bloomFilter: makeFullNodeBloom(), + bloomFilter: MakeFullNodeBloom(), fullNode: true, } } @@ -120,7 +120,7 @@ func (peer *Peer) handshake() error { err = s.Decode(&bloom) if err == nil { sz := len(bloom) - if sz != bloomFilterSize && sz != 0 { + if sz != BloomFilterSize && sz != 0 { return fmt.Errorf("peer [%x] sent bad status message: wrong bloom filter size %d", peer.ID(), sz) } peer.setBloomFilter(bloom) @@ -229,7 +229,7 @@ func (peer *Peer) notifyAboutBloomFilterChange(bloom []byte) error { func (peer *Peer) bloomMatch(env *Envelope) bool { peer.bloomMu.Lock() defer peer.bloomMu.Unlock() - return peer.fullNode || bloomFilterMatch(peer.bloomFilter, env.Bloom()) + return peer.fullNode || BloomFilterMatch(peer.bloomFilter, env.Bloom()) } func (peer *Peer) setBloomFilter(bloom []byte) { @@ -238,13 +238,13 @@ func (peer *Peer) setBloomFilter(bloom []byte) { peer.bloomFilter = bloom peer.fullNode = isFullNode(bloom) if peer.fullNode && peer.bloomFilter == nil { - peer.bloomFilter = makeFullNodeBloom() + peer.bloomFilter = MakeFullNodeBloom() } } -func makeFullNodeBloom() []byte { - bloom := make([]byte, bloomFilterSize) - for i := 0; i < bloomFilterSize; i++ { +func MakeFullNodeBloom() []byte { + bloom := make([]byte, BloomFilterSize) + for i := 0; i < BloomFilterSize; i++ { bloom[i] = 0xFF } return bloom |