From 1025d097fd4e5171dadb2c1a8eeb43b7730b13b6 Mon Sep 17 00:00:00 2001 From: obscuren Date: Tue, 4 Nov 2014 10:49:25 +0100 Subject: [PATCH] removed old bloom --- chain/bloom.go | 47 --------------------------------------------- chain/bloom_test.go | 20 ------------------- 2 files changed, 67 deletions(-) delete mode 100644 chain/bloom.go delete mode 100644 chain/bloom_test.go diff --git a/chain/bloom.go b/chain/bloom.go deleted file mode 100644 index 9d2cf439d2..0000000000 --- a/chain/bloom.go +++ /dev/null @@ -1,47 +0,0 @@ -package chain - -type BloomFilter struct { - bin []byte -} - -func NewBloomFilter(bin []byte) *BloomFilter { - if bin == nil { - bin = make([]byte, 256) - } - - return &BloomFilter{ - bin: bin, - } -} - -func (self *BloomFilter) Set(addr []byte) { - if len(addr) < 8 { - chainlogger.Warnf("err: bloom set to small: %x\n", addr) - - return - } - - for _, i := range addr[len(addr)-8:] { - self.bin[i] = 1 - } -} - -func (self *BloomFilter) Search(addr []byte) bool { - if len(addr) < 8 { - chainlogger.Warnf("err: bloom search to small: %x\n", addr) - - return false - } - - for _, i := range addr[len(addr)-8:] { - if self.bin[i] == 0 { - return false - } - } - - return true -} - -func (self *BloomFilter) Bin() []byte { - return self.bin -} diff --git a/chain/bloom_test.go b/chain/bloom_test.go deleted file mode 100644 index 13c0d94e49..0000000000 --- a/chain/bloom_test.go +++ /dev/null @@ -1,20 +0,0 @@ -package chain - -import "testing" - -func TestBloomFilter(t *testing.T) { - bf := NewBloomFilter(nil) - - a := []byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 0} - bf.Set(a) - - b := []byte{10, 11, 12, 13, 14, 15, 16, 17, 18, 19} - - if bf.Search(a) == false { - t.Error("Expected 'a' to yield true using a bloom filter") - } - - if bf.Search(b) { - t.Error("Expected 'b' not to field trie using a bloom filter") - } -}