diff --git a/src/main.h b/src/main.h index acea707ea..a0ba6e913 100644 --- a/src/main.h +++ b/src/main.h @@ -632,6 +632,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); diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index 55b51a556..563c24cfc 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -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 > mapNewBlock; static vector vNewBlockTemplate; @@ -818,10 +823,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 mapNewBlock; static vector vNewBlockTemplate;