diff options
author | Vlad <gluk256@gmail.com> | 2018-03-01 23:04:09 +0800 |
---|---|---|
committer | Vlad <gluk256@gmail.com> | 2018-03-01 23:04:09 +0800 |
commit | ee75a90ab41fd9a2e5676a2371e529ac2908befa (patch) | |
tree | 4545344b40b16757115b081b6bedd610ceb591e1 /whisper/whisperv6/peer.go | |
parent | 5a150e1b7724c91009a237ab0879cd64844b390d (diff) | |
download | go-tangerine-ee75a90ab41fd9a2e5676a2371e529ac2908befa.tar go-tangerine-ee75a90ab41fd9a2e5676a2371e529ac2908befa.tar.gz go-tangerine-ee75a90ab41fd9a2e5676a2371e529ac2908befa.tar.bz2 go-tangerine-ee75a90ab41fd9a2e5676a2371e529ac2908befa.tar.lz go-tangerine-ee75a90ab41fd9a2e5676a2371e529ac2908befa.tar.xz go-tangerine-ee75a90ab41fd9a2e5676a2371e529ac2908befa.tar.zst go-tangerine-ee75a90ab41fd9a2e5676a2371e529ac2908befa.zip |
whisper: topics replaced by bloom filters
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 |