11 #define LN2SQUARED 0.4804530139182014246671025263266649717305529515945455
12 #define LN2 0.6931471805599453094172321214581765680755001343602552
16 static const unsigned char bit_mask[8] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80};
22 vData(min((unsigned int)(-1 /
LN2SQUARED * nElements * log(nFPRate)), MAX_BLOOM_FILTER_SIZE * 8) / 8),
28 nHashFuncs(min((unsigned int)(vData.size() * 8 / nElements *
LN2), MAX_HASH_FUNCS)),
34 inline unsigned int CBloomFilter::Hash(
unsigned int nHashNum,
const std::vector<unsigned char>& vDataToHash)
const
46 unsigned int nIndex =
Hash(i, vKey);
48 vData[nIndex >> 3] |= bit_mask[7 & nIndex];
57 vector<unsigned char> data(stream.begin(), stream.end());
63 vector<unsigned char> data(hash.
begin(), hash.
end());
75 unsigned int nIndex =
Hash(i, vKey);
77 if (!(
vData[nIndex >> 3] & bit_mask[7 & nIndex]))
87 vector<unsigned char> data(stream.
begin(), stream.
end());
93 vector<unsigned char> data(hash.
begin(), hash.
end());
99 return vData.size() <= MAX_BLOOM_FILTER_SIZE &&
nHashFuncs <= MAX_HASH_FUNCS;
114 for (
unsigned int i = 0; i < tx.
vout.size(); i++)
121 CScript::const_iterator pc = txout.
scriptPubKey.begin();
122 vector<unsigned char> data;
128 if (data.size() != 0 &&
contains(data))
136 vector<vector<unsigned char> > vSolutions;
149 BOOST_FOREACH(
const CTxIn& txin, tx.
vin)
156 CScript::const_iterator pc = txin.
scriptSig.begin();
157 vector<unsigned char> data;
163 if (data.size() != 0 &&
contains(data))
175 for (
unsigned int i = 0; i <
vData.size(); i++)
177 full &=
vData[i] == 0xff;
178 empty &=
vData[i] == 0;
const_iterator begin() const
unsigned int Hash(unsigned int nHashNum, const std::vector< unsigned char > &vDataToHash) const
std::vector< unsigned char > vData
Double ended buffer combining vector and stream-like interfaces.
void insert(const uint256 &hash)
bool IsWithinSizeConstraints() const
unsigned int MurmurHash3(unsigned int nHashSeed, const std::vector< unsigned char > &vDataToHash)
opcodetype
Script opcodes.
An input of a transaction.
std::vector< CTxOut > vout
bool contains(const std::vector< unsigned char > &vKey) const
bool Solver(const CScript &scriptPubKey, txnouttype &typeRet, vector< vector< unsigned char > > &vSolutionsRet)
An output of a transaction.
An outpoint - a combination of a transaction hash and an index n into its vout.
bool IsRelevantAndUpdate(const CTransaction &tx, const uint256 &hash)
bool GetOp(iterator &pc, opcodetype &opcodeRet, std::vector< unsigned char > &vchRet)
The basic transaction that is broadcasted on the network and contained in blocks. ...
const_iterator end() const