Change the state of an announcement to something non-IsSelected(). If it was IsSelected(), the next best announcement will be marked CANDIDATE_BEST.
| 427 | //! Change the state of an announcement to something non-IsSelected(). If it was IsSelected(), the next best |
| 428 | //! announcement will be marked CANDIDATE_BEST. |
| 429 | void ChangeAndReselect(Iter<ByTxHash> it, State new_state) |
| 430 | { |
| 431 | assert(new_state == State::COMPLETED || new_state == State::CANDIDATE_DELAYED); |
| 432 | assert(it != m_index.get<ByTxHash>().end()); |
| 433 | if (it->IsSelected() && it != m_index.get<ByTxHash>().begin()) { |
| 434 | auto it_prev = std::prev(it); |
| 435 | // The next best CANDIDATE_READY, if any, immediately precedes the REQUESTED or CANDIDATE_BEST |
| 436 | // announcement in the ByTxHash index. |
| 437 | if (it_prev->m_txhash == it->m_txhash && it_prev->GetState() == State::CANDIDATE_READY) { |
| 438 | // If one such CANDIDATE_READY exists (for this txhash), convert it to CANDIDATE_BEST. |
| 439 | Modify<ByTxHash>(it_prev, [](Announcement& ann){ ann.SetState(State::CANDIDATE_BEST); }); |
| 440 | } |
| 441 | } |
| 442 | Modify<ByTxHash>(it, [new_state](Announcement& ann){ ann.SetState(new_state); }); |
| 443 | } |
| 444 | |
| 445 | //! Check if 'it' is the only announcement for a given txhash that isn't COMPLETED. |
| 446 | bool IsOnlyNonCompleted(Iter<ByTxHash> it) |
nothing calls this directly
no test coverage detected