Changeset View
Changeset View
Standalone View
Standalone View
src/merkleblock.cpp
Show All 14 Lines | CMerkleBlock::CMerkleBlock(const CBlock &block, CBloomFilter &filter) { | ||||
std::vector<bool> vMatch; | std::vector<bool> vMatch; | ||||
std::vector<uint256> vHashes; | std::vector<uint256> vHashes; | ||||
vMatch.reserve(block.vtx.size()); | vMatch.reserve(block.vtx.size()); | ||||
vHashes.reserve(block.vtx.size()); | vHashes.reserve(block.vtx.size()); | ||||
for (size_t i = 0; i < block.vtx.size(); i++) { | for (size_t i = 0; i < block.vtx.size(); i++) { | ||||
const CTransaction *tx = block.vtx[i].get(); | const CTransaction *tx = block.vtx[i].get(); | ||||
const uint256 &txid = tx->GetId(); | if (filter.HasRelevantOutputsAndUpdate(*tx)) { | ||||
if (filter.IsRelevantAndUpdate(*tx)) { | |||||
vMatch.push_back(true); | vMatch.push_back(true); | ||||
vMatchedTxn.push_back(std::make_pair(i, txid)); | |||||
} else { | } else { | ||||
vMatch.push_back(false); | vMatch.push_back(false); | ||||
} | } | ||||
} | |||||
bvk: How about we remove txid check in `HasRelevantOutputsAndUpdate` and adjust the call-site as… | |||||
bvkUnsubmitted Not Done Inline ActionsActually, my version is buggy -- Outpoints are ignored when only TxID matches. Please ignore it :| bvk: Actually, my version is buggy -- Outpoints are ignored when only TxID matches. Please ignore it… | |||||
markblundebergAuthorUnsubmitted Done Inline ActionsHmm I think it would work as you have written, since the HasRelevantOutputsAndUpdate is not short-circuited out. Anyway I'd prefer to stick with logic that I wrote (just to change minimally), and come up with a better name for HasRelevantOutputsAndUpdate :) markblundeberg: Hmm I think it would work as you have written, since the HasRelevantOutputsAndUpdate is not… | |||||
for (size_t i = 0; i < block.vtx.size(); i++) { | |||||
const CTransaction *tx = block.vtx[i].get(); | |||||
const uint256 &txid = tx->GetId(); | |||||
bool isMatch = vMatch[i] || filter.HasRelevantInputs(*tx); | |||||
vMatch[i] = isMatch; | |||||
if (isMatch) { | |||||
vMatchedTxn.push_back(std::make_pair(i, txid)); | |||||
} | |||||
vHashes.push_back(txid); | vHashes.push_back(txid); | ||||
} | } | ||||
txn = CPartialMerkleTree(vHashes, vMatch); | txn = CPartialMerkleTree(vHashes, vMatch); | ||||
} | } | ||||
CMerkleBlock::CMerkleBlock(const CBlock &block, const std::set<TxId> &txids) { | CMerkleBlock::CMerkleBlock(const CBlock &block, const std::set<TxId> &txids) { | ||||
▲ Show 20 Lines • Show All 185 Lines • Show Last 20 Lines |
How about we remove txid check in HasRelevantOutputsAndUpdate and adjust the call-site as follows:
The new inline function IsRelevantAndUpdate could become:
This is definitely longer -- I am not sure how strict we want to go for issues like these :)