rpc: Avoid initialization-order-fiasco on static CRPCCommand tables

This commit is contained in:
MarcoFalke 2020-04-06 00:21:33 +08:00
parent 4830077494
commit fa1a92224d
No known key found for this signature in database
GPG Key ID: CE2B75697E69A548
6 changed files with 12 additions and 12 deletions

View File

@ -2347,6 +2347,8 @@ UniValue dumptxoutset(const JSONRPCRequest& request)
return result; return result;
} }
void RegisterBlockchainRPCCommands(CRPCTable &t)
{
// clang-format off // clang-format off
static const CRPCCommand commands[] = static const CRPCCommand commands[] =
{ // category name actor (function) argNames { // category name actor (function) argNames
@ -2387,8 +2389,6 @@ static const CRPCCommand commands[] =
}; };
// clang-format on // clang-format on
void RegisterBlockchainRPCCommands(CRPCTable &t)
{
for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++) for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++)
t.appendCommand(commands[vcidx].name, &commands[vcidx]); t.appendCommand(commands[vcidx].name, &commands[vcidx]);
} }

View File

@ -1022,6 +1022,8 @@ static UniValue estimaterawfee(const JSONRPCRequest& request)
return result; return result;
} }
void RegisterMiningRPCCommands(CRPCTable &t)
{
// clang-format off // clang-format off
static const CRPCCommand commands[] = static const CRPCCommand commands[] =
{ // category name actor (function) argNames { // category name actor (function) argNames
@ -1043,8 +1045,6 @@ static const CRPCCommand commands[] =
}; };
// clang-format on // clang-format on
void RegisterMiningRPCCommands(CRPCTable &t)
{
for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++) for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++)
t.appendCommand(commands[vcidx].name, &commands[vcidx]); t.appendCommand(commands[vcidx].name, &commands[vcidx]);
} }

View File

@ -589,6 +589,8 @@ static UniValue echo(const JSONRPCRequest& request)
return request.params; return request.params;
} }
void RegisterMiscRPCCommands(CRPCTable &t)
{
// clang-format off // clang-format off
static const CRPCCommand commands[] = static const CRPCCommand commands[] =
{ // category name actor (function) argNames { // category name actor (function) argNames
@ -610,8 +612,6 @@ static const CRPCCommand commands[] =
}; };
// clang-format on // clang-format on
void RegisterMiscRPCCommands(CRPCTable &t)
{
for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++) for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++)
t.appendCommand(commands[vcidx].name, &commands[vcidx]); t.appendCommand(commands[vcidx].name, &commands[vcidx]);
} }

View File

@ -760,6 +760,8 @@ static UniValue getnodeaddresses(const JSONRPCRequest& request)
return ret; return ret;
} }
void RegisterNetRPCCommands(CRPCTable &t)
{
// clang-format off // clang-format off
static const CRPCCommand commands[] = static const CRPCCommand commands[] =
{ // category name actor (function) argNames { // category name actor (function) argNames
@ -780,8 +782,6 @@ static const CRPCCommand commands[] =
}; };
// clang-format on // clang-format on
void RegisterNetRPCCommands(CRPCTable &t)
{
for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++) for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++)
t.appendCommand(commands[vcidx].name, &commands[vcidx]); t.appendCommand(commands[vcidx].name, &commands[vcidx]);
} }

View File

@ -1813,6 +1813,8 @@ UniValue analyzepsbt(const JSONRPCRequest& request)
return result; return result;
} }
void RegisterRawTransactionRPCCommands(CRPCTable &t)
{
// clang-format off // clang-format off
static const CRPCCommand commands[] = static const CRPCCommand commands[] =
{ // category name actor (function) argNames { // category name actor (function) argNames
@ -1839,8 +1841,6 @@ static const CRPCCommand commands[] =
}; };
// clang-format on // clang-format on
void RegisterRawTransactionRPCCommands(CRPCTable &t)
{
for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++) for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++)
t.appendCommand(commands[vcidx].name, &commands[vcidx]); t.appendCommand(commands[vcidx].name, &commands[vcidx]);
} }

View File

@ -4242,6 +4242,8 @@ UniValue importprunedfunds(const JSONRPCRequest& request);
UniValue removeprunedfunds(const JSONRPCRequest& request); UniValue removeprunedfunds(const JSONRPCRequest& request);
UniValue importmulti(const JSONRPCRequest& request); UniValue importmulti(const JSONRPCRequest& request);
void RegisterWalletRPCCommands(interfaces::Chain& chain, std::vector<std::unique_ptr<interfaces::Handler>>& handlers)
{
// clang-format off // clang-format off
static const CRPCCommand commands[] = static const CRPCCommand commands[] =
{ // category name actor (function) argNames { // category name actor (function) argNames
@ -4305,8 +4307,6 @@ static const CRPCCommand commands[] =
}; };
// clang-format on // clang-format on
void RegisterWalletRPCCommands(interfaces::Chain& chain, std::vector<std::unique_ptr<interfaces::Handler>>& handlers)
{
for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++) for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++)
handlers.emplace_back(chain.handleRpc(commands[vcidx])); handlers.emplace_back(chain.handleRpc(commands[vcidx]));
} }