Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/init.cpp b/init.cpp
- index 04bdd68..c59d88d 100644
- --- a/init.cpp
- +++ b/init.cpp
- @@ -115,6 +115,7 @@ bool AppInit(int argc, char* argv[])
- } catch (...) {
- PrintException(NULL, "AppInit()");
- }
- + initialization_completed = true;
- if (!fRet)
- Shutdown(NULL);
- return fRet;
- @@ -122,6 +123,9 @@ bool AppInit(int argc, char* argv[])
- bool AppInit2(int argc, char* argv[])
- {
- + if (GetBoolArg("-server") || fDaemon)
- + CreateThread(ThreadRPCServer, NULL);
- +
- #ifdef _MSC_VER
- // Turn off microsoft heap dump noise
- _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
- @@ -443,9 +447,6 @@ bool AppInit2(int argc, char* argv[])
- if (!CreateThread(StartNode, NULL))
- wxMessageBox("Error: CreateThread(StartNode) failed", "Bitcoin");
- - if (GetBoolArg("-server") || fDaemon)
- - CreateThread(ThreadRPCServer, NULL);
- -
- #if defined(__WXMSW__) && defined(GUI)
- if (fFirstRun)
- SetStartOnSystemStartup(true);
- diff --git a/rpc.cpp b/rpc.cpp
- index 69b09bc..6bdfe5e 100644
- --- a/rpc.cpp
- +++ b/rpc.cpp
- @@ -28,6 +28,8 @@ void ThreadRPCServer2(void* parg);
- typedef Value(*rpcfn_type)(const Array& params, bool fHelp);
- extern map<string, rpcfn_type> mapCallTable;
- +bool initialization_completed = false;
- +
- Object JSONRPCError(int code, const string& message)
- {
- @@ -146,6 +148,12 @@ Value help(const Array& params, bool fHelp)
- return strRet;
- }
- +Value isinitialized(const Array& params, bool fHelp)
- +{
- + if (fHelp || params.size() > 0)
- + throw runtime_error("isinitialized\n");
- + return initialization_completed;
- +}
- Value stop(const Array& params, bool fHelp)
- {
- @@ -1307,6 +1315,7 @@ Value getwork(const Array& params, bool fHelp)
- pair<string, rpcfn_type> pCallTable[] =
- {
- make_pair("help", &help),
- + make_pair("isinitialized", &isinitialized),
- make_pair("stop", &stop),
- make_pair("getblockcount", &getblockcount),
- make_pair("getblocknumber", &getblocknumber),
- @@ -1348,6 +1357,7 @@ map<string, rpcfn_type> mapCallTable(pCallTable, pCallTable + sizeof(pCallTable)
- string pAllowInSafeMode[] =
- {
- "help",
- + "isinitialized",
- "stop",
- "getblockcount",
- "getblocknumber",
- @@ -1806,6 +1816,8 @@ void ThreadRPCServer2(void* parg)
- if (valMethod.type() != str_type)
- throw JSONRPCError(-32600, "Method must be a string");
- string strMethod = valMethod.get_str();
- + if (!initialization_completed && strMethod != "help" && strMethod != "isinitialized")
- + throw JSONRPCError(-42000, "test");
- if (strMethod != "getwork")
- printf("ThreadRPCServer method=%s\n", strMethod.c_str());
- diff --git a/rpc.h b/rpc.h
- index 48a7b8a..50a1733 100644
- --- a/rpc.h
- +++ b/rpc.h
- @@ -4,3 +4,4 @@
- void ThreadRPCServer(void* parg);
- int CommandLineRPC(int argc, char *argv[]);
- +extern bool initialization_completed;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement