Check if 'it' is the only announcement for a given txhash that isn't COMPLETED.
| 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 |