From bd9a439bab26dd38cc933e1cb1330a38ada53aee Mon Sep 17 00:00:00 2001 From: cinnamoncoin Date: Wed, 20 Aug 2014 01:31:23 +0000 Subject: [PATCH] fix rpc console crash in non server mode corrects the crashing of rpc console with getblocktemplate getwork getwork2 and other commands --- src/bitcoinrpc.cpp | 9 +-------- src/bitcoinrpc.h | 4 +++- src/init.cpp | 4 +++- src/makefile.mingw | 4 ++-- src/rpcmining.cpp | 13 +++++++++++++ 5 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp index 144b95c..3205a4f 100644 --- a/src/bitcoinrpc.cpp +++ b/src/bitcoinrpc.cpp @@ -31,10 +31,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 @@ -732,8 +728,6 @@ static void RPCAcceptHandler(boost::shared_ptr< basic_socket_acceptorstop(); diff --git a/src/bitcoinrpc.h b/src/bitcoinrpc.h index 0442e7a..2022ee2 100644 --- a/src/bitcoinrpc.h +++ b/src/bitcoinrpc.h @@ -123,7 +123,9 @@ class CRPCTable }; 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 b6f6068..0813f28 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -97,7 +97,8 @@ void Shutdown() RenameThread("bitcoin-shutoff"); nTransactionsUpdated++; StopRPCThreads(); - bitdb.Flush(false); + ShutdownRPCMining(); + bitdb.Flush(false); StopNode(); { LOCK(cs_main); @@ -1083,6 +1084,7 @@ bool AppInit2(boost::thread_group& threadGroup) StartNode(threadGroup); + InitRPCMining(); if (fServer) StartRPCThreads(); diff --git a/src/makefile.mingw b/src/makefile.mingw index 7b3f55f..7a707fc 100644 --- a/src/makefile.mingw +++ b/src/makefile.mingw @@ -29,7 +29,7 @@ INCLUDEPATHS= \ -I"c:/deps/boost_1_55_0" \ -I"c:/deps/db-4.8.30.NC/build_unix" \ -I"c:/deps/miniupnpc" \ - -I"c:/deps/openssl-1.0.1g/include" + -I"c:/deps/openssl-1.0.1h/include" LIBPATHS= \ -L"$(CURDIR)/leveldb" \ @@ -37,7 +37,7 @@ LIBPATHS= \ -L"c:/deps/boost_1_55_0/stage/lib" \ -L"c:/deps/db-4.8.30.NC/build_unix" \ -L"c:/deps/miniupnpc" \ - -L"c:/deps/openssl-1.0.1g" + -L"c:/deps/openssl-1.0.1h" LIBS= \ -l leveldb \ diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index 4fdd317..8a3b141 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -12,6 +12,19 @@ using namespace json_spirit; using namespace std; +static CReserveKey* pMiningKey = NULL; + +void InitRPCMining() +{ + + pMiningKey = new CReserveKey(pwalletMain); +} + +void ShutdownRPCMining() +{ + delete pMiningKey; pMiningKey = NULL; +} + // Return average network hashes per second based on the last 'lookup' blocks, // or from the last difficulty change if 'lookup' is nonpositive. // If 'height' is nonnegative, compute the estimate at the time when a given block was found.