 |
PRCYCoin
2.0.0.7rc1
P2P Digital Currency
|
Go to the documentation of this file.
17 #define LN2SQUARED 0.4804530139182014246671025263266649717305529515945455
18 #define LN2 0.6931471805599453094172321214581765680755001343602552
27 vData(
std::min((unsigned int)(-1 /
LN2SQUARED * nElements * log(nFPRate)), MAX_BLOOM_FILTER_SIZE * 8) / 8),
35 nHashFuncs(
std::min((unsigned int)(vData.size() * 8 / nElements *
LN2), MAX_HASH_FUNCS)),
43 vData((unsigned int)(-1 /
LN2SQUARED * nElements * log(nFPRate)) / 8),
46 nHashFuncs((unsigned int)(vData.size() * 8 / nElements *
LN2)),
52 inline unsigned int CBloomFilter::Hash(
unsigned int nHashNum,
const std::vector<unsigned char>& vDataToHash)
const
62 for (
unsigned int i = 0; i <
nHashFuncs; i++) {
63 unsigned int nIndex =
Hash(i, vKey);
65 vData[nIndex >> 3] |= (1 << (7 & nIndex));
74 std::vector<unsigned char> data(stream.
begin(), stream.
end());
80 std::vector<unsigned char> data(hash.
begin(), hash.
end());
90 for (
unsigned int i = 0; i <
nHashFuncs; i++) {
91 unsigned int nIndex =
Hash(i, vKey);
93 if (!(
vData[nIndex >> 3] & (1 << (7 & nIndex))))
103 std::vector<unsigned char> data(stream.
begin(), stream.
end());
109 std::vector<unsigned char> data(hash.
begin(), hash.
end());
128 return vData.size() <= MAX_BLOOM_FILTER_SIZE &&
nHashFuncs <= MAX_HASH_FUNCS;
144 for (
unsigned int i = 0; i < tx.
vout.size(); i++) {
151 std::vector<unsigned char> data;
156 if (data.size() != 0 &&
contains(data)) {
162 std::vector<std::vector<unsigned char> > vSolutions;
182 std::vector<unsigned char> data;
187 if (data.size() != 0 &&
contains(data))
199 for (
unsigned int i = 0; i <
vData.size(); i++) {
200 full &=
vData[i] == 0xff;
201 empty &=
vData[i] == 0;
208 b1(nElements * 2, fpRate, 0), b2(nElements * 2, fpRate, 0)
236 std::vector<unsigned char> data(hash.
begin(), hash.
end());
250 std::vector<unsigned char> data(hash.
begin(), hash.
end());
256 unsigned int nNewTweak =
GetRand(std::numeric_limits<unsigned int>::max());
An input of a transaction.
bool contains(const std::vector< unsigned char > &vKey) const
void reset(unsigned int nNewTweak)
void insert(const std::vector< unsigned char > &vKey)
bool IsWithinSizeConstraints() const
True if the size is <= MAX_BLOOM_FILTER_SIZE and the number of hash functions is <= MAX_HASH_FUNCS (c...
const_iterator begin() const
@ BLOOM_UPDATE_P2PUBKEY_ONLY
unsigned int MurmurHash3(unsigned int nHashSeed, const std::vector< unsigned char > &vDataToHash)
unsigned int Hash(unsigned int nHashNum, const std::vector< unsigned char > &vDataToHash) const
std::vector< unsigned char > vData
void UpdateEmptyFull()
Checks for empty and full filters to avoid wasting cpu.
bool contains(const std::vector< unsigned char > &vKey) const
The basic transaction that is broadcasted on the network and contained in blocks.
uint64_t GetRand(uint64_t nMax)
CRollingBloomFilter(unsigned int nElements, double nFPRate)
An output of a transaction.
void insert(const std::vector< unsigned char > &vKey)
std::vector< CTxOut > vout
const_iterator end() const
bool GetOp(iterator &pc, opcodetype &opcodeRet, std::vector< unsigned char > &vchRet)
256-bit unsigned big integer.
bool Solver(const CKeyStore &keystore, const CScript &scriptPubKey, uint256 hash, int nHashType, CScript &scriptSigRet, txnouttype &whichTypeRet)
Sign scriptPubKey with private keys stored in keystore, given transaction hash and hash type.
Double ended buffer combining vector and stream-like interfaces.
const uint256 & GetHash() const
An outpoint - a combination of a transaction hash and an index n into its vout.
bool IsRelevantAndUpdate(const CTransaction &tx)
Also adds any outputs which match the filter to the filter (to match their spending txes)
opcodetype
Script opcodes.