feat: replace assert to error in p2p code of Asset Lock

It is impossible situation which will never happen.
But better to change it to exception for better error-prune implementation
in case someone will decide to change this code:

    const auto quorums = qman.ScanQuorums(llmqType, pindexTip, quorums_to_scan);
    if (bool isActive = std::any_of(quorums.begin(), quorums.end(), [&](const auto &q) { return q->qc->quorumHash == quorumHash; }); !isActive) {
        return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-assetunlock-too-old-quorum");
    }
    ...
    const auto quorum = qman.GetQuorum(llmqType, quorumHash);
    assert(quorum); <-- for sure exist because we just scanned quorums
This commit is contained in:
Konstantin Akimov 2024-10-28 22:25:11 +07:00
parent c97f5f5ca5
commit e43ca6243a
No known key found for this signature in database
GPG Key ID: 2176C4A5D01EA524

View File

@ -138,7 +138,10 @@ bool CAssetUnlockPayload::VerifySig(const llmq::CQuorumManager& qman, const uint
}
const auto quorum = qman.GetQuorum(llmqType, quorumHash);
assert(quorum);
// quorum must be valid at this point. Let's check and throw error just in case
if (!quorum) {
return state.Invalid(TxValidationResult::TX_CONSENSUS, "internal-error");
}
const uint256 requestId = ::SerializeHash(std::make_pair(ASSETUNLOCK_REQUESTID_PREFIX, index));