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:
Daniel Kraft
2014-10-29 18:08:31 +01:00
parent be32b5212b
commit af82884ab7
6 changed files with 108 additions and 30 deletions

View File

@@ -52,6 +52,7 @@ enum RPCErrorCode
RPC_VERIFY_ERROR = -25, // General error during transaction or block submission
RPC_VERIFY_REJECTED = -26, // Transaction or block was rejected by network rules
RPC_VERIFY_ALREADY_IN_CHAIN = -27, // Transaction already in chain
RPC_IN_WARMUP = -28, // Client still warming up
// Aliases for backward compatibility
RPC_TRANSACTION_ERROR = RPC_VERIFY_ERROR,