MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / IsRelevantAndUpdate

Method IsRelevantAndUpdate

src/bloom.cpp:133–201  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

131}
132
133bool CBloomFilter::IsRelevantAndUpdate(const CTransaction& tx)
134{
135 bool fFound = false;
136 // Match if the filter contains the hash of tx
137 // for finding tx when they appear in a block
138 if (isFull)
139 return true;
140 if (isEmpty)
141 return false;
142 const uint256& hash = tx.GetHash();
143 if (contains(hash))
144 fFound = true;
145
146 for (unsigned int i = 0; i < tx.vout.size(); i++)
147 {
148 const CTxOut& txout = tx.vout[i];
149 // Match if the filter contains any arbitrary script data element in any scriptPubKey in tx
150 // If this matches, also add the specific output that was matched.
151 // This means clients don't have to update the filter themselves when a new relevant tx
152 // is discovered in order to find spending transactions, which avoids round-tripping and race conditions.
153 CScript::const_iterator pc = txout.scriptPubKey.begin();
154 std::vector<unsigned char> data;
155 while (pc < txout.scriptPubKey.end())
156 {
157 opcodetype opcode;
158 if (!txout.scriptPubKey.GetOp(pc, opcode, data))
159 break;
160 if (data.size() != 0 && contains(data))
161 {
162 fFound = true;
163 if ((nFlags & BLOOM_UPDATE_MASK) == BLOOM_UPDATE_ALL)
164 insert(COutPoint(hash, i));
165 else if ((nFlags & BLOOM_UPDATE_MASK) == BLOOM_UPDATE_P2PUBKEY_ONLY)
166 {
167 txnouttype type;
168 std::vector<std::vector<unsigned char> > vSolutions;
169 if (Solver(txout.scriptPubKey, type, vSolutions) &&
170 (type == TX_PUBKEY || type == TX_MULTISIG))
171 insert(COutPoint(hash, i));
172 }
173 break;
174 }
175 }
176 }
177
178 if (fFound)
179 return true;
180
181 for (const CTxIn& txin : tx.vin)
182 {
183 // Match if the filter contains an outpoint tx spends
184 if (contains(txin.prevout))
185 return true;
186
187 // Match if the filter contains any arbitrary script data element in any scriptSig in tx
188 CScript::const_iterator pc = txin.scriptSig.begin();
189 std::vector<unsigned char> data;
190 while (pc < txin.scriptSig.end())

Callers 3

SendMessagesMethod · 0.80
CMerkleBlockMethod · 0.80
BOOST_AUTO_TEST_CASEFunction · 0.80

Calls 8

insertFunction · 0.85
SolverFunction · 0.85
GetOpMethod · 0.80
COutPointClass · 0.70
GetHashMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by 1

BOOST_AUTO_TEST_CASEFunction · 0.64