From d98bf10f23e0e633ff2ff33075a353d30bf862b4 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Thu, 30 May 2013 15:51:41 +0200 Subject: Move pMiningKey init out of StartRPCThreads This commit decouples the pMiningKey initialization and shutdown from the RPC threads. `getwork` and `getblocktemplate` rely on pMiningKey, and can also be ran from the debug window in the UI even when the RPC server is not running. Solves issue #2706. --- src/rpcmining.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/rpcmining.cpp') diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index b8b7459634..845e7f1f9c 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -11,6 +11,21 @@ using namespace json_spirit; using namespace std; +// Key used by getwork/getblocktemplate miners. +// Allocated in InitRPCMining, free'd in ShutdownRPCMining +static CReserveKey* pMiningKey = NULL; + +void InitRPCMining() +{ + // getwork/getblocktemplate mining rewards paid here: + pMiningKey = new CReserveKey(pwalletMain); +} + +void ShutdownRPCMining() +{ + delete pMiningKey; pMiningKey = NULL; +} + Value getgenerate(const Array& params, bool fHelp) { if (fHelp || params.size() != 0) -- cgit v1.2.3