Skip to content

Commit fa1a922

Browse files
author
MarcoFalke
committed
rpc: Avoid initialization-order-fiasco on static CRPCCommand tables
1 parent 4830077 commit fa1a922

File tree

6 files changed

+12
-12
lines changed

6 files changed

+12
-12
lines changed

src/rpc/blockchain.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2347,6 +2347,8 @@ UniValue dumptxoutset(const JSONRPCRequest& request)
23472347
return result;
23482348
}
23492349

2350+
void RegisterBlockchainRPCCommands(CRPCTable &t)
2351+
{
23502352
// clang-format off
23512353
static const CRPCCommand commands[] =
23522354
{ // category name actor (function) argNames
@@ -2387,8 +2389,6 @@ static const CRPCCommand commands[] =
23872389
};
23882390
// clang-format on
23892391

2390-
void RegisterBlockchainRPCCommands(CRPCTable &t)
2391-
{
23922392
for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++)
23932393
t.appendCommand(commands[vcidx].name, &commands[vcidx]);
23942394
}

src/rpc/mining.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,6 +1022,8 @@ static UniValue estimaterawfee(const JSONRPCRequest& request)
10221022
return result;
10231023
}
10241024

1025+
void RegisterMiningRPCCommands(CRPCTable &t)
1026+
{
10251027
// clang-format off
10261028
static const CRPCCommand commands[] =
10271029
{ // category name actor (function) argNames
@@ -1043,8 +1045,6 @@ static const CRPCCommand commands[] =
10431045
};
10441046
// clang-format on
10451047

1046-
void RegisterMiningRPCCommands(CRPCTable &t)
1047-
{
10481048
for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++)
10491049
t.appendCommand(commands[vcidx].name, &commands[vcidx]);
10501050
}

src/rpc/misc.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,8 @@ static UniValue echo(const JSONRPCRequest& request)
589589
return request.params;
590590
}
591591

592+
void RegisterMiscRPCCommands(CRPCTable &t)
593+
{
592594
// clang-format off
593595
static const CRPCCommand commands[] =
594596
{ // category name actor (function) argNames
@@ -610,8 +612,6 @@ static const CRPCCommand commands[] =
610612
};
611613
// clang-format on
612614

613-
void RegisterMiscRPCCommands(CRPCTable &t)
614-
{
615615
for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++)
616616
t.appendCommand(commands[vcidx].name, &commands[vcidx]);
617617
}

src/rpc/net.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,8 @@ static UniValue getnodeaddresses(const JSONRPCRequest& request)
760760
return ret;
761761
}
762762

763+
void RegisterNetRPCCommands(CRPCTable &t)
764+
{
763765
// clang-format off
764766
static const CRPCCommand commands[] =
765767
{ // category name actor (function) argNames
@@ -780,8 +782,6 @@ static const CRPCCommand commands[] =
780782
};
781783
// clang-format on
782784

783-
void RegisterNetRPCCommands(CRPCTable &t)
784-
{
785785
for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++)
786786
t.appendCommand(commands[vcidx].name, &commands[vcidx]);
787787
}

src/rpc/rawtransaction.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1813,6 +1813,8 @@ UniValue analyzepsbt(const JSONRPCRequest& request)
18131813
return result;
18141814
}
18151815

1816+
void RegisterRawTransactionRPCCommands(CRPCTable &t)
1817+
{
18161818
// clang-format off
18171819
static const CRPCCommand commands[] =
18181820
{ // category name actor (function) argNames
@@ -1839,8 +1841,6 @@ static const CRPCCommand commands[] =
18391841
};
18401842
// clang-format on
18411843

1842-
void RegisterRawTransactionRPCCommands(CRPCTable &t)
1843-
{
18441844
for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++)
18451845
t.appendCommand(commands[vcidx].name, &commands[vcidx]);
18461846
}

src/wallet/rpcwallet.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4242,6 +4242,8 @@ UniValue importprunedfunds(const JSONRPCRequest& request);
42424242
UniValue removeprunedfunds(const JSONRPCRequest& request);
42434243
UniValue importmulti(const JSONRPCRequest& request);
42444244

4245+
void RegisterWalletRPCCommands(interfaces::Chain& chain, std::vector<std::unique_ptr<interfaces::Handler>>& handlers)
4246+
{
42454247
// clang-format off
42464248
static const CRPCCommand commands[] =
42474249
{ // category name actor (function) argNames
@@ -4305,8 +4307,6 @@ static const CRPCCommand commands[] =
43054307
};
43064308
// clang-format on
43074309

4308-
void RegisterWalletRPCCommands(interfaces::Chain& chain, std::vector<std::unique_ptr<interfaces::Handler>>& handlers)
4309-
{
43104310
for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++)
43114311
handlers.emplace_back(chain.handleRpc(commands[vcidx]));
43124312
}

0 commit comments

Comments
 (0)