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