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

Method IsOnlyNonCompleted

src/txrequest.cpp:436–450  ·  view source on GitHub ↗

Check if 'it' is the only announcement for a given txhash that isn't COMPLETED.

Source from the content-addressed store, hash-verified

434
435 //! Check if 'it' is the only announcement for a given txhash that isn't COMPLETED.
436 bool IsOnlyNonCompleted(Iter<ByTxHash> it)
437 {
438 assert(it != m_index.get<ByTxHash>().end());
439 assert(it->GetState() != State::COMPLETED); // Not allowed to call this on COMPLETED announcements.
440
441 // This announcement has a predecessor that belongs to the same txhash. Due to ordering, and the
442 // fact that 'it' is not COMPLETED, its predecessor cannot be COMPLETED here.
443 if (it != m_index.get<ByTxHash>().begin() && std::prev(it)->m_gtxid.ToUint256() == it->m_gtxid.ToUint256()) return false;
444
445 // This announcement has a successor that belongs to the same txhash, and is not COMPLETED.
446 if (std::next(it) != m_index.get<ByTxHash>().end() && std::next(it)->m_gtxid.ToUint256() == it->m_gtxid.ToUint256() &&
447 std::next(it)->GetState() != State::COMPLETED) return false;
448
449 return true;
450 }
451
452 /** Convert any announcement to a COMPLETED one. If there are no non-COMPLETED announcements left for this
453 * txhash, they are deleted. If this was a REQUESTED announcement, and there are other CANDIDATEs left, the

Callers

nothing calls this directly

Calls 3

endMethod · 0.45
GetStateMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected