MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / ComputeTxHashInfo

Function ComputeTxHashInfo

src/txrequest.cpp:273–294  ·  view source on GitHub ↗

Compute the TxHashInfo map. Only used for sanity checking. */

Source from the content-addressed store, hash-verified

271
272/** Compute the TxHashInfo map. Only used for sanity checking. */
273std::map<uint256, TxHashInfo> ComputeTxHashInfo(const Index& index, const PriorityComputer& computer)
274{
275 std::map<uint256, TxHashInfo> ret;
276 for (const Announcement& ann : index) {
277 TxHashInfo& info = ret[ann.m_gtxid.ToUint256()];
278 // Classify how many announcements of each state we have for this txhash.
279 info.m_candidate_delayed += (ann.GetState() == State::CANDIDATE_DELAYED);
280 info.m_candidate_ready += (ann.GetState() == State::CANDIDATE_READY);
281 info.m_candidate_best += (ann.GetState() == State::CANDIDATE_BEST);
282 info.m_requested += (ann.GetState() == State::REQUESTED);
283 // And track the priority of the best CANDIDATE_READY/CANDIDATE_BEST announcements.
284 if (ann.GetState() == State::CANDIDATE_BEST) {
285 info.m_priority_candidate_best = computer(ann);
286 }
287 if (ann.GetState() == State::CANDIDATE_READY) {
288 info.m_priority_best_candidate_ready = std::max(info.m_priority_best_candidate_ready, computer(ann));
289 }
290 // Also keep track of which peers this txhash has an announcement for (so we can detect duplicates).
291 info.m_peers.push_back(ann.m_peer);
292 }
293 return ret;
294}
295
296} // namespace
297

Callers 1

SanityCheckMethod · 0.85

Calls 2

GetStateMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected