mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-19 23:03:45 +01:00
Removed main.h dependency from rpcserver.cpp
Rebased by @laanwj:
- update for RPC methods added since 84d13ee: setmocktime,
invalidateblock, reconsiderblock. Only the first, setmocktime, required a change,
the other two are thread safe.
This commit is contained in:
committed by
Wladimir J. van der Laan
parent
6b5f5294bb
commit
4401b2d7c5
22
src/init.cpp
22
src/init.cpp
@@ -234,6 +234,26 @@ bool static Bind(const CService &addr, unsigned int flags) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void OnRPCStopped()
|
||||
{
|
||||
cvBlockChange.notify_all();
|
||||
LogPrint("rpc", "RPC stopped.\n");
|
||||
}
|
||||
|
||||
void OnRPCPreCommand(const CRPCCommand& cmd)
|
||||
{
|
||||
#ifdef ENABLE_WALLET
|
||||
if (cmd.reqWallet && !pwalletMain)
|
||||
throw JSONRPCError(RPC_METHOD_NOT_FOUND, "Method not found (disabled)");
|
||||
#endif
|
||||
|
||||
// Observe safe mode
|
||||
string strWarning = GetWarnings("rpc");
|
||||
if (strWarning != "" && !GetBoolArg("-disablesafemode", false) &&
|
||||
!cmd.okSafeMode)
|
||||
throw JSONRPCError(RPC_FORBIDDEN_BY_SAFE_MODE, string("Safe mode: ") + strWarning);
|
||||
}
|
||||
|
||||
std::string HelpMessage(HelpMessageMode mode)
|
||||
{
|
||||
// When adding new options to the categories, please keep and ensure alphabetical ordering.
|
||||
@@ -802,6 +822,8 @@ bool AppInit2(boost::thread_group& threadGroup)
|
||||
if (fServer)
|
||||
{
|
||||
uiInterface.InitMessage.connect(SetRPCWarmupStatus);
|
||||
RPCServer::OnStopped(&OnRPCStopped);
|
||||
RPCServer::OnPreCommand(&OnRPCPreCommand);
|
||||
StartRPCThreads();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user