aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Garzik <[email protected]>2013-05-30 09:15:16 -0700
committerJeff Garzik <[email protected]>2013-05-30 09:15:16 -0700
commit6bc6d57303e1c9d469d31a43da83f944a53ab549 (patch)
treec8cd9fade7925a8065bbaf6c0972f8b8d8e7d804
parentMerge pull request #2705 from robbak/crash_zero_size_peers.dat (diff)
parentMove pMiningKey init out of StartRPCThreads (diff)
downloaddiscoin-6bc6d57303e1c9d469d31a43da83f944a53ab549.tar.xz
discoin-6bc6d57303e1c9d469d31a43da83f944a53ab549.zip
Merge pull request #2716 from laanwj/2013_05_30_getwork
Move pMiningKey init out of StartRPCThreads
-rw-r--r--src/bitcoinrpc.cpp9
-rw-r--r--src/bitcoinrpc.h4
-rw-r--r--src/init.cpp3
-rw-r--r--src/rpcmining.cpp15
4 files changed, 21 insertions, 10 deletions
diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp
index 5d64fb767..a1d76e181 100644
--- a/src/bitcoinrpc.cpp
+++ b/src/bitcoinrpc.cpp
@@ -30,10 +30,6 @@ using namespace boost;
using namespace boost::asio;
using namespace json_spirit;
-// Key used by getwork/getblocktemplate miners.
-// Allocated in StartRPCThreads, free'd in StopRPCThreads
-CReserveKey* pMiningKey = NULL;
-
static std::string strRPCUserColonPass;
// These are created by StartRPCThreads, destroyed in StopRPCThreads
@@ -727,9 +723,6 @@ static void RPCAcceptHandler(boost::shared_ptr< basic_socket_acceptor<Protocol,
void StartRPCThreads()
{
- // getwork/getblocktemplate mining rewards paid here:
- pMiningKey = new CReserveKey(pwalletMain);
-
strRPCUserColonPass = mapArgs["-rpcuser"] + ":" + mapArgs["-rpcpassword"];
if ((mapArgs["-rpcpassword"] == "") ||
(mapArgs["-rpcuser"] == mapArgs["-rpcpassword"]))
@@ -849,8 +842,6 @@ void StartRPCThreads()
void StopRPCThreads()
{
- delete pMiningKey; pMiningKey = NULL;
-
if (rpc_io_service == NULL) return;
deadlineTimers.clear();
diff --git a/src/bitcoinrpc.h b/src/bitcoinrpc.h
index 279e48aec..44c657f8d 100644
--- a/src/bitcoinrpc.h
+++ b/src/bitcoinrpc.h
@@ -129,7 +129,9 @@ public:
};
extern const CRPCTable tableRPC;
-extern CReserveKey* pMiningKey;
+
+extern void InitRPCMining();
+extern void ShutdownRPCMining();
extern int64 nWalletUnlockTime;
extern int64 AmountFromValue(const json_spirit::Value& value);
diff --git a/src/init.cpp b/src/init.cpp
index aaa7d4320..226e93e9a 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -97,6 +97,7 @@ void Shutdown()
RenameThread("bitcoin-shutoff");
nTransactionsUpdated++;
StopRPCThreads();
+ ShutdownRPCMining();
bitdb.Flush(false);
StopNode();
{
@@ -1088,6 +1089,8 @@ bool AppInit2(boost::thread_group& threadGroup)
StartNode(threadGroup);
+ // InitRPCMining is needed here so getwork/getblocktemplate in the GUI debug console works properly.
+ InitRPCMining();
if (fServer)
StartRPCThreads();
diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp
index b8b745963..845e7f1f9 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)