Skip to content

Commit 301bd41

Browse files
committed
scripted-diff: Rename InitInterfaces to NodeContext
-BEGIN VERIFY SCRIPT- s() { git grep -l "$1" src | xargs sed -i "s/$1/$2/g"; } s 'struct InitInterfaces' 'struct NodeContext' s 'InitInterfaces interfaces' 'NodeContext node' s 'InitInterfaces& interfaces' 'NodeContext\& node' s 'InitInterfaces m_interfaces' 'NodeContext m_context' s 'InitInterfaces\* g_rpc_interfaces' 'NodeContext* g_rpc_node' s 'g_rpc_interfaces = &interfaces' 'g_rpc_node = \&node' s 'g_rpc_interfaces' 'g_rpc_node' s 'm_interfaces' 'm_context' s 'interfaces\.chain' 'node.chain' s '\(AppInitMain\|Shutdown\|Construct\)(interfaces)' '\1(node)' s 'init interfaces' 'chain clients' -END VERIFY SCRIPT-
1 parent cfec3e0 commit 301bd41

File tree

11 files changed

+41
-41
lines changed

11 files changed

+41
-41
lines changed

src/bitcoind.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ static void WaitForShutdown()
3939
//
4040
static bool AppInit(int argc, char* argv[])
4141
{
42-
InitInterfaces interfaces;
43-
interfaces.chain = interfaces::MakeChain();
42+
NodeContext node;
43+
node.chain = interfaces::MakeChain();
4444

4545
bool fRet = false;
4646

@@ -142,7 +142,7 @@ static bool AppInit(int argc, char* argv[])
142142
// If locking the data directory failed, exit immediately
143143
return false;
144144
}
145-
fRet = AppInitMain(interfaces);
145+
fRet = AppInitMain(node);
146146
}
147147
catch (const std::exception& e) {
148148
PrintExceptionContinue(&e, "AppInit()");
@@ -156,7 +156,7 @@ static bool AppInit(int argc, char* argv[])
156156
} else {
157157
WaitForShutdown();
158158
}
159-
Shutdown(interfaces);
159+
Shutdown(node);
160160

161161
return fRet;
162162
}

src/dummywallet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class DummyWalletInit : public WalletInitInterface {
1919
bool HasWalletSupport() const override {return false;}
2020
void AddWalletOptions() const override;
2121
bool ParameterInteraction() const override {return true;}
22-
void Construct(InitInterfaces& interfaces) const override {LogPrintf("No wallet support compiled in!\n");}
22+
void Construct(NodeContext& node) const override {LogPrintf("No wallet support compiled in!\n");}
2323
};
2424

2525
void DummyWalletInit::AddWalletOptions() const

src/init.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ void Interrupt()
170170
ForEachBlockFilterIndex([](BlockFilterIndex& index) { index.Interrupt(); });
171171
}
172172

173-
void Shutdown(InitInterfaces& interfaces)
173+
void Shutdown(NodeContext& node)
174174
{
175175
LogPrintf("%s: In progress...\n", __func__);
176176
static CCriticalSection cs_Shutdown;
@@ -189,7 +189,7 @@ void Shutdown(InitInterfaces& interfaces)
189189
StopREST();
190190
StopRPC();
191191
StopHTTPServer();
192-
for (const auto& client : interfaces.chain_clients) {
192+
for (const auto& client : node.chain_clients) {
193193
client->flush();
194194
}
195195
StopMapPort();
@@ -261,7 +261,7 @@ void Shutdown(InitInterfaces& interfaces)
261261
}
262262
pblocktree.reset();
263263
}
264-
for (const auto& client : interfaces.chain_clients) {
264+
for (const auto& client : node.chain_clients) {
265265
client->stop();
266266
}
267267

@@ -280,7 +280,7 @@ void Shutdown(InitInterfaces& interfaces)
280280
} catch (const fs::filesystem_error& e) {
281281
LogPrintf("%s: Unable to remove PID file: %s\n", __func__, fsbridge::get_filesystem_error_message(e));
282282
}
283-
interfaces.chain_clients.clear();
283+
node.chain_clients.clear();
284284
UnregisterAllValidationInterfaces();
285285
GetMainSignals().UnregisterBackgroundSignalScheduler();
286286
GetMainSignals().UnregisterWithMempoolSignals(mempool);
@@ -1207,7 +1207,7 @@ bool AppInitLockDataDirectory()
12071207
return true;
12081208
}
12091209

1210-
bool AppInitMain(InitInterfaces& interfaces)
1210+
bool AppInitMain(NodeContext& node)
12111211
{
12121212
const CChainParams& chainparams = Params();
12131213
// ********************************************************* Step 4a: application initialization
@@ -1275,16 +1275,16 @@ bool AppInitMain(InitInterfaces& interfaces)
12751275
// according to -wallet and -disablewallet options. This only constructs
12761276
// the interfaces, it doesn't load wallet data. Wallets actually get loaded
12771277
// when load() and start() interface methods are called below.
1278-
g_wallet_init_interface.Construct(interfaces);
1278+
g_wallet_init_interface.Construct(node);
12791279

12801280
/* Register RPC commands regardless of -server setting so they will be
12811281
* available in the GUI RPC console even if external calls are disabled.
12821282
*/
12831283
RegisterAllCoreRPCCommands(tableRPC);
1284-
for (const auto& client : interfaces.chain_clients) {
1284+
for (const auto& client : node.chain_clients) {
12851285
client->registerRpcs();
12861286
}
1287-
g_rpc_interfaces = &interfaces;
1287+
g_rpc_node = &node;
12881288
#if ENABLE_ZMQ
12891289
RegisterZMQRPCCommands(tableRPC);
12901290
#endif
@@ -1302,7 +1302,7 @@ bool AppInitMain(InitInterfaces& interfaces)
13021302
}
13031303

13041304
// ********************************************************* Step 5: verify wallet database integrity
1305-
for (const auto& client : interfaces.chain_clients) {
1305+
for (const auto& client : node.chain_clients) {
13061306
if (!client->verify()) {
13071307
return false;
13081308
}
@@ -1661,7 +1661,7 @@ bool AppInitMain(InitInterfaces& interfaces)
16611661
}
16621662

16631663
// ********************************************************* Step 9: load wallet
1664-
for (const auto& client : interfaces.chain_clients) {
1664+
for (const auto& client : node.chain_clients) {
16651665
if (!client->load()) {
16661666
return false;
16671667
}
@@ -1815,7 +1815,7 @@ bool AppInitMain(InitInterfaces& interfaces)
18151815
SetRPCWarmupFinished();
18161816
uiInterface.InitMessage(_("Done loading").translated);
18171817

1818-
for (const auto& client : interfaces.chain_clients) {
1818+
for (const auto& client : node.chain_clients) {
18191819
client->start(scheduler);
18201820
}
18211821

src/init.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class ChainClient;
1616
} // namespace interfaces
1717

1818
//! Pointers to interfaces used during init and destroyed on shutdown.
19-
struct InitInterfaces
19+
struct NodeContext
2020
{
2121
std::unique_ptr<interfaces::Chain> chain;
2222
std::vector<std::unique_ptr<interfaces::ChainClient>> chain_clients;
@@ -29,7 +29,7 @@ class thread_group;
2929

3030
/** Interrupt threads */
3131
void Interrupt();
32-
void Shutdown(InitInterfaces& interfaces);
32+
void Shutdown(NodeContext& node);
3333
//!Initialize the logging infrastructure
3434
void InitLogging();
3535
//!Parameter interaction: change current parameters depending on various rules
@@ -63,7 +63,7 @@ bool AppInitLockDataDirectory();
6363
* @note This should only be done after daemonization. Call Shutdown() if this function fails.
6464
* @pre Parameters should be parsed and config file should be read, AppInitLockDataDirectory should have been called.
6565
*/
66-
bool AppInitMain(InitInterfaces& interfaces);
66+
bool AppInitMain(NodeContext& node);
6767

6868
/**
6969
* Setup the arguments for gArgs

src/interfaces/node.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ namespace {
5252
class NodeImpl : public Node
5353
{
5454
public:
55-
NodeImpl() { m_interfaces.chain = MakeChain(); }
55+
NodeImpl() { m_context.chain = MakeChain(); }
5656
void initError(const std::string& message) override { InitError(message); }
5757
bool parseParameters(int argc, const char* const argv[], std::string& error) override
5858
{
@@ -75,11 +75,11 @@ class NodeImpl : public Node
7575
return AppInitBasicSetup() && AppInitParameterInteraction() && AppInitSanityChecks() &&
7676
AppInitLockDataDirectory();
7777
}
78-
bool appInitMain() override { return AppInitMain(m_interfaces); }
78+
bool appInitMain() override { return AppInitMain(m_context); }
7979
void appShutdown() override
8080
{
8181
Interrupt();
82-
Shutdown(m_interfaces);
82+
Shutdown(m_context);
8383
}
8484
void startShutdown() override { StartShutdown(); }
8585
bool shutdownRequested() override { return ShutdownRequested(); }
@@ -255,12 +255,12 @@ class NodeImpl : public Node
255255
}
256256
std::unique_ptr<Wallet> loadWallet(const std::string& name, std::string& error, std::vector<std::string>& warnings) override
257257
{
258-
return MakeWallet(LoadWallet(*m_interfaces.chain, name, error, warnings));
258+
return MakeWallet(LoadWallet(*m_context.chain, name, error, warnings));
259259
}
260260
WalletCreationStatus createWallet(const SecureString& passphrase, uint64_t wallet_creation_flags, const std::string& name, std::string& error, std::vector<std::string>& warnings, std::unique_ptr<Wallet>& result) override
261261
{
262262
std::shared_ptr<CWallet> wallet;
263-
WalletCreationStatus status = CreateWallet(*m_interfaces.chain, passphrase, wallet_creation_flags, name, error, warnings, wallet);
263+
WalletCreationStatus status = CreateWallet(*m_context.chain, passphrase, wallet_creation_flags, name, error, warnings, wallet);
264264
result = MakeWallet(wallet);
265265
return status;
266266
}
@@ -315,7 +315,7 @@ class NodeImpl : public Node
315315
/* verification progress is unused when a header was received */ 0);
316316
}));
317317
}
318-
InitInterfaces m_interfaces;
318+
NodeContext m_context;
319319
};
320320

321321
} // namespace

src/rpc/util.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
#include <tuple>
1515

16-
InitInterfaces* g_rpc_interfaces = nullptr;
16+
NodeContext* g_rpc_node = nullptr;
1717

1818
void RPCTypeCheck(const UniValue& params,
1919
const std::list<UniValueType>& typesExpected,

src/rpc/util.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525
class FillableSigningProvider;
2626
class CPubKey;
2727
class CScript;
28-
struct InitInterfaces;
28+
struct NodeContext;
2929

3030
//! Pointers to interfaces that need to be accessible from RPC methods. Due to
3131
//! limitations of the RPC framework, there's currently no direct way to pass in
3232
//! state to RPC method implementations.
33-
extern InitInterfaces* g_rpc_interfaces;
33+
extern NodeContext* g_rpc_node;
3434

3535
/** Wrapper for UniValue::VType, which includes typeAny:
3636
* Used to denote don't care type. */

src/test/rpc_tests.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,14 @@ BOOST_AUTO_TEST_CASE(rpc_rawsign)
112112
std::string notsigned = r.get_str();
113113
std::string privkey1 = "\"KzsXybp9jX64P5ekX1KUxRQ79Jht9uzW7LorgwE65i5rWACL6LQe\"";
114114
std::string privkey2 = "\"Kyhdf5LuKTRx4ge69ybABsiUAWjVRK4XGxAKk2FQLp2HjGMy87Z4\"";
115-
InitInterfaces interfaces;
116-
interfaces.chain = interfaces::MakeChain();
117-
g_rpc_interfaces = &interfaces;
115+
NodeContext node;
116+
node.chain = interfaces::MakeChain();
117+
g_rpc_node = &node;
118118
r = CallRPC(std::string("signrawtransactionwithkey ")+notsigned+" [] "+prevout);
119119
BOOST_CHECK(find_value(r.get_obj(), "complete").get_bool() == false);
120120
r = CallRPC(std::string("signrawtransactionwithkey ")+notsigned+" ["+privkey1+","+privkey2+"] "+prevout);
121121
BOOST_CHECK(find_value(r.get_obj(), "complete").get_bool() == true);
122-
g_rpc_interfaces = nullptr;
122+
g_rpc_node = nullptr;
123123
}
124124

125125
BOOST_AUTO_TEST_CASE(rpc_createraw_op_return)

src/wallet/init.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ class WalletInit : public WalletInitInterface {
2525
//! Wallets parameter interaction
2626
bool ParameterInteraction() const override;
2727

28-
//! Add wallets that should be opened to list of init interfaces.
29-
void Construct(InitInterfaces& interfaces) const override;
28+
//! Add wallets that should be opened to list of chain clients.
29+
void Construct(NodeContext& node) const override;
3030
};
3131

3232
const WalletInitInterface& g_wallet_init_interface = WalletInit();
@@ -125,12 +125,12 @@ bool WalletInit::ParameterInteraction() const
125125
return true;
126126
}
127127

128-
void WalletInit::Construct(InitInterfaces& interfaces) const
128+
void WalletInit::Construct(NodeContext& node) const
129129
{
130130
if (gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET)) {
131131
LogPrintf("Wallet disabled!\n");
132132
return;
133133
}
134134
gArgs.SoftSetArg("-wallet", "");
135-
interfaces.chain_clients.emplace_back(interfaces::MakeWalletClient(*interfaces.chain, gArgs.GetArgs("-wallet")));
135+
node.chain_clients.emplace_back(interfaces::MakeWalletClient(*node.chain, gArgs.GetArgs("-wallet")));
136136
}

src/wallet/rpcwallet.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2574,7 +2574,7 @@ static UniValue loadwallet(const JSONRPCRequest& request)
25742574

25752575
std::string error;
25762576
std::vector<std::string> warning;
2577-
std::shared_ptr<CWallet> const wallet = LoadWallet(*g_rpc_interfaces->chain, location, error, warning);
2577+
std::shared_ptr<CWallet> const wallet = LoadWallet(*g_rpc_node->chain, location, error, warning);
25782578
if (!wallet) throw JSONRPCError(RPC_WALLET_ERROR, error);
25792579

25802580
UniValue obj(UniValue::VOBJ);
@@ -2700,7 +2700,7 @@ static UniValue createwallet(const JSONRPCRequest& request)
27002700

27012701
std::string error;
27022702
std::shared_ptr<CWallet> wallet;
2703-
WalletCreationStatus status = CreateWallet(*g_rpc_interfaces->chain, passphrase, flags, request.params[0].get_str(), error, warnings, wallet);
2703+
WalletCreationStatus status = CreateWallet(*g_rpc_node->chain, passphrase, flags, request.params[0].get_str(), error, warnings, wallet);
27042704
switch (status) {
27052705
case WalletCreationStatus::CREATION_FAILED:
27062706
throw JSONRPCError(RPC_WALLET_ERROR, error);

0 commit comments

Comments
 (0)