aboutsummaryrefslogtreecommitdiff
path: root/src/bloom.cpp
diff options
context:
space:
mode:
authorMatt Corallo <git@bluematt.me>2013-02-24 20:36:59 -0500
committerMatt Corallo <git@bluematt.me>2013-02-24 20:36:59 -0500
commitcbfc77352d095d562860fa8695ada5ac73cf7f67 (patch)
treeacbd0f91b5aec585c6b5b48b986923be26cf30cf /src/bloom.cpp
parent0bd573d6662e2c07fe7afcf55cb926ce9be95644 (diff)
downloadbitcoin-cbfc77352d095d562860fa8695ada5ac73cf7f67.tar.xz
Short-circuit bloom checking if we will always return true.
This allows full nodes to use bloom filters as an optimization.
Diffstat (limited to 'src/bloom.cpp')
-rw-r--r--src/bloom.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/bloom.cpp b/src/bloom.cpp
index 36f5e50134..d9ec2efa81 100644
--- a/src/bloom.cpp
+++ b/src/bloom.cpp
@@ -37,6 +37,8 @@ inline unsigned int CBloomFilter::Hash(unsigned int nHashNum, const std::vector<
void CBloomFilter::insert(const vector<unsigned char>& vKey)
{
+ if (vData.size() == 1 && vData[0] == 0xff)
+ return;
for (unsigned int i = 0; i < nHashFuncs; i++)
{
unsigned int nIndex = Hash(i, vKey);
@@ -61,6 +63,8 @@ void CBloomFilter::insert(const uint256& hash)
bool CBloomFilter::contains(const vector<unsigned char>& vKey) const
{
+ if (vData.size() == 1 && vData[0] == 0xff)
+ return true;
for (unsigned int i = 0; i < nHashFuncs; i++)
{
unsigned int nIndex = Hash(i, vKey);