Changeset View
Changeset View
Standalone View
Standalone View
src/merkleblock.cpp
Show All 12 Lines | CMerkleBlock::CMerkleBlock(const CBlock &block, CBloomFilter &filter) { | ||||
header = block.GetBlockHeader(); | header = block.GetBlockHeader(); | ||||
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++) { | ||||
deadalnix: You can use a C++11 style loop hereas you don't need the index. | |||||
const CTransaction *tx = block.vtx[i].get(); | const CTransaction *tx = block.vtx[i].get(); | ||||
const uint256 &txid = tx->GetId(); | if (filter.IsRelevantBesidesInputsAndUpdate(*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); | ||||
deadalnixUnsubmitted Done Inline ActionsvMatch.push_back(filter.IsRelevantBesidesInputsAndUpdate(*tx)); deadalnix: vMatch.push_back(filter.IsRelevantBesidesInputsAndUpdate(*tx)); | |||||
} | } | ||||
} | |||||
for (size_t i = 0; i < block.vtx.size(); i++) { | |||||
const CTransaction *tx = block.vtx[i].get(); | |||||
const uint256 &txid = tx->GetId(); | |||||
deadalnixUnsubmitted Done Inline ActionsPresumably, the txid is a TxId. deadalnix: Presumably, the txid is a TxId. | |||||
bool isMatch = vMatch[i] || filter.HasRelevantInputs(*tx); | |||||
vMatch[i] = isMatch; | |||||
if (isMatch) { | |||||
deadalnixUnsubmitted Done Inline ActionsThis whole thing is fairly inelegant. if (!vMatch[i]) { vMatch[i] = filter.HasRelevantInputs(*tx); } if (vMatch[i]) { vMatchedTxn.push_back(std::make_pair(i, txid)); } Something like this would be less strange that creating a temporary to immediately assign it and then use it. deadalnix: This whole thing is fairly inelegant.
if (!vMatch[i]) {
vMatch[i] = filter. | |||||
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 |
You can use a C++11 style loop hereas you don't need the index.