Skip to content

Commit

Permalink
Unified smsg return codes.
Browse files Browse the repository at this point in the history
  • Loading branch information
tecnovert committed Oct 30, 2017
1 parent 2578371 commit a9d4828
Show file tree
Hide file tree
Showing 5 changed files with 305 additions and 354 deletions.
2 changes: 1 addition & 1 deletion src/net_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2704,7 +2704,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
// message would be undesirable as we transmit it ourselves.
}

else if (2 != SecureMsgReceiveData(pfrom, strCommand, vRecv))
else if (SMSG_UNKNOWN_MESSAGE != SecureMsgReceiveData(pfrom, strCommand, vRecv))
{

} else
Expand Down
27 changes: 7 additions & 20 deletions src/rpc/smessage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,14 +458,7 @@ UniValue smsgaddkey(const JSONRPCRequest &request)
if (rv != 0)
{
result.pushKV("result", "Public key not added to db.");
switch (rv)
{
case 2: result.pushKV("reason", "publicKey is invalid."); break;
case 3: result.pushKV("reason", "publicKey does not match address."); break;
case 4: result.pushKV("reason", "address is already in db."); break;
case 5: result.pushKV("reason", "address is invalid."); break;
default: result.pushKV("reason", "error."); break;
};
result.pushKV("reason", SecureMessageGetString(rv));
} else
{
result.pushKV("result", "Added public key to db.");
Expand All @@ -492,22 +485,17 @@ UniValue smsggetpubkey(const JSONRPCRequest &request)
int rv = SecureMsgGetLocalPublicKey(address, publicKey);
switch (rv)
{
case 0:
case SMSG_NO_ERROR:
result.pushKV("result", "Success.");
result.pushKV("address", address);
result.pushKV("publickey", publicKey);
return result; // success, don't check db
case 2:
case 3:
result.pushKV("result", "Failed.");
result.pushKV("message", "Invalid address.");
return result;
case 4:
case SMSG_WALLET_NO_PUBKEY:
break; // check db
//case 1:
default:
result.pushKV("result", "Failed.");
result.pushKV("message", "Error.");
result.pushKV("reason", SecureMessageGetString(rv));
return result;
};

Expand All @@ -527,7 +515,7 @@ UniValue smsggetpubkey(const JSONRPCRequest &request)

switch (rv)
{
case 0:
case SMSG_NO_ERROR:
if (!cpkFromDB.IsValid()
|| !cpkFromDB.IsCompressed())
{
Expand All @@ -543,14 +531,13 @@ UniValue smsggetpubkey(const JSONRPCRequest &request)
result.pushKV("publickey", publicKey);
};
break;
case 2:
case SMSG_PUBKEY_NOT_EXISTS:
result.pushKV("result", "Failed.");
result.pushKV("message", "Address not found in wallet or db.");
return result;
//case 1:
default:
result.pushKV("result", "Failed.");
result.pushKV("message", "Error, GetStoredKey().");
result.pushKV("reason", SecureMessageGetString(rv));
return result;
};

Expand Down
Loading

0 comments on commit a9d4828

Please sign in to comment.