It was the Bitcointalk forum that inspired us to create Bitcointalksearch.org - Bitcointalk is an excellent site that should be the default page for anybody dealing in cryptocurrency, since it is a virtual gold-mine of data. However, our experience and user feedback led us create our site; Bitcointalk's search is slow, and difficult to get the results you need, because you need to log in first to find anything useful - furthermore, there are rate limiters for their search functionality.
The aim of our project is to create a faster website that yields more results and faster without having to create an account and eliminate the need to log in - your personal data, therefore, will never be in jeopardy since we are not asking for any of your data and you don't need to provide them to use our site with all of its capabilities.
We created this website with the sole purpose of users being able to search quickly and efficiently in the field of cryptocurrency so they will have access to the latest and most accurate information and thereby assisting the crypto-community at large.
import hashlib
class CuckooFilter:
def __init__(self, capacity, false_positive_rate):
# Calculate the size of the filter and the number of hash functions needed
# based on the desired capacity and false positive rate
self.size = int(-1 * capacity * math.log(false_positive_rate) / (math.log(2) ** 2))
self.num_hashes = int(round(math.log(2) * self.size / capacity))
self.buckets = [[None, None] for _ in range(self.size)]
#print(self.size,self.num_hashes)
def add(self, element):
# Hash the element to one of the two buckets at each position
for i in range(self.num_hashes):
h = self._hash(element, i)
if self.buckets[h][0] is None:
self.buckets[h][0] = element
return
elif self.buckets[h][1] is None:
self.buckets[h][1] = element
return
# If both buckets are occupied, "kick out" one of the elements
# and rehash it to a new position
else:
e = self.buckets[h][i % 2]
self.buckets[h][i % 2] = element
element = e
# If the element could not be added to the filter, raise an exception
raise Exception("Filter is full")
def contains(self, element):
# Check if the element is present in either of the two buckets at each position
for i in range(self.num_hashes):
h = self._hash(element, i)
if self.buckets[h][0] == element or self.buckets[h][1] == element:
return True
return False
def delete(self, element):
# Set the value in the occupied bucket to None to indicate that the element is deleted
for i in range(self.num_hashes):
h = self._hash(element, i)
if self.buckets[h][0] == element:
self.buckets[h][0] = None
return
elif self.buckets[h][1] == element:
self.buckets[h][1] = None
return
def _hash(self, element, i):
# Hash the element to a position in the filter using the ith hash function
m = hashlib.sha1()
m.update(element.encode())
m.update(str(i).encode())
return int(m.hexdigest(), 16) % self.size
# Create a cuckoo filter with a capacity of 100 elements and a false positive rate of 0.1
filter = CuckooFilter(capacity=100, false_positive_rate=0.1)
# Add some elements to the filter
filter.add("apple")
filter.add("banana")
filter.add("cherry")
# Test for membership
print("is apple in filter",filter.contains("apple")) # prints True
print("is pear in filter",filter.contains("pear")) # prints False
# Delete an element from the filter
filter.delete("cherry")
# Test for membership again
print("is cherry in filter after delete",filter.contains("cherry")) # prints False