Changeset View
Changeset View
Standalone View
Standalone View
src/bloom.cpp
Show First 20 Lines • Show All 118 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
bool CBloomFilter::IsRelevantAndUpdate(const CTransaction &tx) { | bool CBloomFilter::IsRelevantAndUpdate(const CTransaction &tx) { | ||||
bool fFound = false; | bool fFound = false; | ||||
// Match if the filter contains the hash of tx for finding tx when they | // Match if the filter contains the hash of tx for finding tx when they | ||||
// appear in a block | // appear in a block | ||||
if (isFull) return true; | if (isFull) return true; | ||||
if (isEmpty) return false; | if (isEmpty) return false; | ||||
const uint256 &txid = tx.GetId(); | const uint256 &txhash = tx.GetHash(); | ||||
if (contains(txid)) fFound = true; | if (contains(txhash)) fFound = true; | ||||
for (unsigned int i = 0; i < tx.vout.size(); i++) { | for (unsigned int i = 0; i < tx.vout.size(); i++) { | ||||
const CTxOut &txout = tx.vout[i]; | const CTxOut &txout = tx.vout[i]; | ||||
// Match if the filter contains any arbitrary script data element in any | // Match if the filter contains any arbitrary script data element in any | ||||
// scriptPubKey in tx. If this matches, also add the specific output | // scriptPubKey in tx. If this matches, also add the specific output | ||||
// that was matched. This means clients don't have to update the filter | // that was matched. This means clients don't have to update the filter | ||||
// themselves when a new relevant tx is discovered in order to find | // themselves when a new relevant tx is discovered in order to find | ||||
// spending transactions, which avoids round-tripping and race | // spending transactions, which avoids round-tripping and race | ||||
// conditions. | // conditions. | ||||
CScript::const_iterator pc = txout.scriptPubKey.begin(); | CScript::const_iterator pc = txout.scriptPubKey.begin(); | ||||
std::vector<uint8_t> data; | std::vector<uint8_t> data; | ||||
while (pc < txout.scriptPubKey.end()) { | while (pc < txout.scriptPubKey.end()) { | ||||
opcodetype opcode; | opcodetype opcode; | ||||
if (!txout.scriptPubKey.GetOp(pc, opcode, data)) break; | if (!txout.scriptPubKey.GetOp(pc, opcode, data)) break; | ||||
if (data.size() != 0 && contains(data)) { | if (data.size() != 0 && contains(data)) { | ||||
fFound = true; | fFound = true; | ||||
if ((nFlags & BLOOM_UPDATE_MASK) == BLOOM_UPDATE_ALL) | if ((nFlags & BLOOM_UPDATE_MASK) == BLOOM_UPDATE_ALL) | ||||
insert(COutPoint(txid, i)); | insert(COutPoint((unspentid_t)txhash, i)); | ||||
else if ((nFlags & BLOOM_UPDATE_MASK) == | else if ((nFlags & BLOOM_UPDATE_MASK) == | ||||
BLOOM_UPDATE_P2PUBKEY_ONLY) { | BLOOM_UPDATE_P2PUBKEY_ONLY) { | ||||
txnouttype type; | txnouttype type; | ||||
std::vector<std::vector<uint8_t>> vSolutions; | std::vector<std::vector<uint8_t>> vSolutions; | ||||
if (Solver(txout.scriptPubKey, type, vSolutions) && | if (Solver(txout.scriptPubKey, type, vSolutions) && | ||||
(type == TX_PUBKEY || type == TX_MULTISIG)) | (type == TX_PUBKEY || type == TX_MULTISIG)) | ||||
insert(COutPoint(txid, i)); | insert(COutPoint((unspentid_t)txhash, i)); | ||||
} | } | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
if (fFound) return true; | if (fFound) return true; | ||||
▲ Show 20 Lines • Show All 137 Lines • Show Last 20 Lines |