MCPcopy Create free account
hub / github.com/ElementsProject/elements / ComputeTxHashInfo

Function ComputeTxHashInfo

src/txrequest.cpp:278–299  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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

Callers 1

SanityCheckMethod · 0.85

Calls 2

GetStateMethod · 0.80
push_backMethod · 0.45

Tested by

no test coverage detected