mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 06:28:31 +01:00
Add "warmup mode" for RPC server.
Start the RPC server before doing all the (expensive) startup initialisations like loading the block index. Until the node is ready, return all calls immediately with a new error signalling "in warmup" with an appropriate status message (similar to the init message). This is useful for RPC clients to know that the server is there (e. g., they don't have to start it) but not yet available. It is used in Namecoin and Huntercoin already for some time, and there exists a UI hooked onto the RPC interface that actively uses this to its advantage.
This commit is contained in:
14
src/init.cpp
14
src/init.cpp
@@ -752,6 +752,17 @@ bool AppInit2(boost::thread_group& threadGroup)
|
||||
threadGroup.create_thread(&ThreadScriptCheck);
|
||||
}
|
||||
|
||||
/* Start the RPC server already. It will be started in "warmup" mode
|
||||
* and not really process calls already (but it will signify connections
|
||||
* that the server is there and will be ready later). Warmup mode will
|
||||
* be disabled when initialisation is finished.
|
||||
*/
|
||||
if (fServer)
|
||||
{
|
||||
uiInterface.InitMessage.connect(SetRPCWarmupStatus);
|
||||
StartRPCThreads();
|
||||
}
|
||||
|
||||
int64_t nStart;
|
||||
|
||||
// ********************************************************* Step 5: verify wallet database integrity
|
||||
@@ -1248,8 +1259,6 @@ bool AppInit2(boost::thread_group& threadGroup)
|
||||
#endif
|
||||
|
||||
StartNode(threadGroup);
|
||||
if (fServer)
|
||||
StartRPCThreads();
|
||||
|
||||
#ifdef ENABLE_WALLET
|
||||
// Generate coins in the background
|
||||
@@ -1259,6 +1268,7 @@ bool AppInit2(boost::thread_group& threadGroup)
|
||||
|
||||
// ********************************************************* Step 11: finished
|
||||
|
||||
SetRPCWarmupFinished();
|
||||
uiInterface.InitMessage(_("Done loading"));
|
||||
|
||||
#ifdef ENABLE_WALLET
|
||||
|
||||
Reference in New Issue
Block a user