aboutsummaryrefslogtreecommitdiff
path: root/src/rpcmining.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2012-10-04 09:34:44 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2012-10-04 15:49:15 +0200
commit738835d7b8ab80bd0812805f197471c54c72d7f9 (patch)
treef5ac75781dada5de5b30d53ba17b7e0674c57e5a /src/rpcmining.cpp
parent0547b02af78dcf2d84e4905b56c7f95d9582b2f9 (diff)
Document RPC error codes
Replace all "magic values" in RPCError(...) by constants.
Diffstat (limited to 'src/rpcmining.cpp')
-rw-r--r--src/rpcmining.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp
index 2954b9ee57..96712482d5 100644
--- a/src/rpcmining.cpp
+++ b/src/rpcmining.cpp
@@ -96,10 +96,10 @@ Value getwork(const Array& params, bool fHelp)
"If [data] is specified, tries to solve the block and returns true if it was successful.");
if (vNodes.empty())
- throw JSONRPCError(-9, "Bitcoin is not connected!");
+ throw JSONRPCError(RPC_CLIENT_NOT_CONNECTED, "Bitcoin is not connected!");
if (IsInitialBlockDownload())
- throw JSONRPCError(-10, "Bitcoin is downloading blocks...");
+ throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "Bitcoin is downloading blocks...");
typedef map<uint256, pair<CBlock*, CScript> > mapNewBlock_t;
static mapNewBlock_t mapNewBlock; // FIXME: thread safety
@@ -136,7 +136,7 @@ Value getwork(const Array& params, bool fHelp)
// Create new block
pblock = CreateNewBlock(reservekey);
if (!pblock)
- throw JSONRPCError(-7, "Out of memory");
+ throw JSONRPCError(RPC_OUT_OF_MEMORY, "Out of memory");
vNewBlock.push_back(pblock);
// Need to update only after we know CreateNewBlock succeeded
@@ -174,7 +174,7 @@ Value getwork(const Array& params, bool fHelp)
// Parse parameters
vector<unsigned char> vchData = ParseHex(params[0].get_str());
if (vchData.size() != 128)
- throw JSONRPCError(-8, "Invalid parameter");
+ throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter");
CBlock* pdata = (CBlock*)&vchData[0];
// Byte reverse
@@ -230,17 +230,17 @@ Value getblocktemplate(const Array& params, bool fHelp)
/* Do nothing */
}
else
- throw JSONRPCError(-8, "Invalid mode");
+ throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid mode");
}
if (strMode != "template")
- throw JSONRPCError(-8, "Invalid mode");
+ throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid mode");
if (vNodes.empty())
- throw JSONRPCError(-9, "Bitcoin is not connected!");
+ throw JSONRPCError(RPC_CLIENT_NOT_CONNECTED, "Bitcoin is not connected!");
if (IsInitialBlockDownload())
- throw JSONRPCError(-10, "Bitcoin is downloading blocks...");
+ throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "Bitcoin is downloading blocks...");
static CReserveKey reservekey(pwalletMain);
@@ -268,7 +268,7 @@ Value getblocktemplate(const Array& params, bool fHelp)
}
pblock = CreateNewBlock(reservekey);
if (!pblock)
- throw JSONRPCError(-7, "Out of memory");
+ throw JSONRPCError(RPC_OUT_OF_MEMORY, "Out of memory");
// Need to update only after we know CreateNewBlock succeeded
pindexPrev = pindexPrevNew;
@@ -369,7 +369,7 @@ Value submitblock(const Array& params, bool fHelp)
ssBlock >> block;
}
catch (std::exception &e) {
- throw JSONRPCError(-22, "Block decode failed");
+ throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Block decode failed");
}
bool fAccepted = ProcessBlock(NULL, &block);