feat(llmq): add human-readable message alongside error code (#4916)

This commit is contained in:
Kittywhiskers Van Gogh 2022-07-14 23:23:42 +05:30 committed by GitHub
parent 6c0a63360f
commit 04b7bcf52a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 1 deletions

View File

@ -46,6 +46,31 @@ static uint256 MakeQuorumKey(const CQuorum& q)
return hw.GetHash();
}
std::string CQuorumDataRequest::GetErrorString() const
{
switch (nError) {
case (Errors::NONE):
return "NONE";
case (Errors::QUORUM_TYPE_INVALID):
return "QUORUM_TYPE_INVALID";
case (Errors::QUORUM_BLOCK_NOT_FOUND):
return "QUORUM_BLOCK_NOT_FOUND";
case (Errors::QUORUM_NOT_FOUND):
return "QUORUM_NOT_FOUND";
case (Errors::MASTERNODE_IS_NO_MEMBER):
return "MASTERNODE_IS_NO_MEMBER";
case (Errors::QUORUM_VERIFICATION_VECTOR_MISSING):
return "QUORUM_VERIFICATION_VECTOR_MISSING";
case (Errors::ENCRYPTED_CONTRIBUTIONS_MISSING):
return "ENCRYPTED_CONTRIBUTIONS_MISSING";
case (Errors::UNDEFINED):
return "UNDEFINED";
default:
return "UNDEFINED";
}
return "UNDEFINED";
}
CQuorum::CQuorum(const Consensus::LLMQParams& _params, CBLSWorker& _blsWorker) : params(_params), blsCache(_blsWorker)
{
}
@ -654,7 +679,7 @@ void CQuorumManager::ProcessMessage(CNode* pFrom, const std::string& msg_type, C
}
if (request.GetError() != CQuorumDataRequest::Errors::NONE) {
errorHandler(strprintf("Error %d", request.GetError()), 0);
errorHandler(strprintf("Error %d (%s)", request.GetError(), request.GetErrorString()), 0);
return;
}

View File

@ -101,6 +101,7 @@ public:
void SetError(Errors nErrorIn) { nError = nErrorIn; }
Errors GetError() const { return nError; }
std::string GetErrorString() const;
bool IsExpired() const { return (GetTime() - nTime) >= EXPIRATION_TIMEOUT; }
bool IsProcessed() const { return fProcessed; }