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

Method MakeCompleted

src/txrequest.cpp:465–486  ·  view source on GitHub ↗

Convert any announcement to a COMPLETED one. If there are no non-COMPLETED announcements left for this * txhash, they are deleted. If this was a REQUESTED announcement, and there are other CANDIDATEs left, the * best one is made CANDIDATE_BEST. Returns whether the announcement still exists. */

Source from the content-addressed store, hash-verified

463 * txhash, they are deleted. If this was a REQUESTED announcement, and there are other CANDIDATEs left, the
464 * best one is made CANDIDATE_BEST. Returns whether the announcement still exists. */
465 bool MakeCompleted(Iter<ByTxHash> it)
466 {
467 assert(it != m_index.get<ByTxHash>().end());
468
469 // Nothing to be done if it's already COMPLETED.
470 if (it->GetState() == State::COMPLETED) return true;
471
472 if (IsOnlyNonCompleted(it)) {
473 // This is the last non-COMPLETED announcement for this txhash. Delete all.
474 uint256 txhash = it->m_txhash;
475 do {
476 it = Erase<ByTxHash>(it);
477 } while (it != m_index.get<ByTxHash>().end() && it->m_txhash == txhash);
478 return false;
479 }
480
481 // Mark the announcement COMPLETED, and select the next best announcement (the first CANDIDATE_READY) if
482 // needed.
483 ChangeAndReselect(it, State::COMPLETED);
484
485 return true;
486 }
487
488 //! Make the data structure consistent with a given point in time:
489 //! - REQUESTED announcements with expiry <= now are turned into COMPLETED.

Callers

nothing calls this directly

Calls 2

GetStateMethod · 0.80
endMethod · 0.45

Tested by

no test coverage detected