Disable AuxPoW RPC commands until switchover block

AuxPoW RPC commands now return a failure message until the switchover block on the respective
network. Also cleaned up RPC error values to use enum values rather than magic numbers.
This commit is contained in:
Ross Nicoll 2014-08-18 19:08:54 +01:00
parent 5c78fef3c1
commit bfdc854dbd
No known key found for this signature in database
GPG key ID: 9142E5F7E533CE3B
2 changed files with 17 additions and 4 deletions

View file

@ -621,6 +621,9 @@ bool ConnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex, C
// Add this block to the block index, and if necessary, switch the active block chain to this
bool AddToBlockIndex(CBlock& block, CValidationState& state, const CDiskBlockPos& pos);
// Get the block at which AuxPoW is enabled for this network
int GetAuxPowStartBlock();
// Context-independent validity checks
bool CheckBlockHeader(const CBlockHeader& block, CValidationState& state, int nHeight, bool fCheckPOW = true);
bool CheckBlock(const CBlock& block, CValidationState& state, int nHeight, bool fCheckPOW = true, bool fCheckMerkleRoot = true);

View file

@ -657,10 +657,15 @@ Value getworkaux(const Array& params, bool fHelp)
);
if (vNodes.empty())
throw JSONRPCError(-9, "Dogecoin is not connected!");
throw JSONRPCError(RPC_CLIENT_NOT_CONNECTED, "Dogecoin is not connected!");
if (IsInitialBlockDownload())
throw JSONRPCError(-10, "Dogecoin is downloading blocks...");
throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "Dogecoin is downloading blocks...");
// We use height plus one because we're testing the next block
if ((chainActive.Tip()->nHeight+1) < GetAuxPowStartBlock()) {
throw JSONRPCError(RPC_METHOD_NOT_FOUND, "getworkaux method is not available until switch-over block.");
}
static map<uint256, pair<CBlock*, unsigned int> > mapNewBlock;
static vector<CBlockTemplate*> vNewBlockTemplate;
@ -817,10 +822,15 @@ Value getauxblock(const Array& params, bool fHelp)
"the aux proof of work and returns true if it was successful.");
if (vNodes.empty())
throw JSONRPCError(-9, "Dogecoin is not connected!");
throw JSONRPCError(RPC_CLIENT_NOT_CONNECTED, "Dogecoin is not connected!");
if (IsInitialBlockDownload())
throw JSONRPCError(-10, "Dogecoin is downloading blocks...");
throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "Dogecoin is downloading blocks...");
// We use height plus one because we're testing the next block
if ((chainActive.Tip()->nHeight+1) < GetAuxPowStartBlock()) {
throw JSONRPCError(RPC_METHOD_NOT_FOUND, "getauxblock method is not available until switch-over block.");
}
static map<uint256, CBlock*> mapNewBlock;
static vector<CBlockTemplate*> vNewBlockTemplate;