Skip to content

Commit

Permalink
Merge #2569: [Cleanup] Remove and deglobalize system.h global variables.
Browse files Browse the repository at this point in the history
5ab02bc Deglobalize strBudgetMode variable inside budget manager. (furszy)
8796c89 Remove unneeded global fDaemon (furszy)
b1d4992 Remove unneeded global strMasterNodeAddr (furszy)

Pull request description:

  Straightforward cleanup of global variables from `system.h` that are not needed to be global.

ACKs for top commit:
  random-zebra:
    utACK 5ab02bc

Tree-SHA512: a77dd7caa6337551cd2d9aab5336c37d9b29924940254a198782e1b02c4ab630542c6a5302a23c131f9f450ba9b896fa2e4eeba85fc19d12e97866722bd7f552
  • Loading branch information
furszy committed Sep 29, 2021
2 parents c80a25b + 5ab02bc commit 9c64f9b
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 17 deletions.
7 changes: 2 additions & 5 deletions src/activemasternode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,15 +235,12 @@ OperationResult initMasternode(const std::string& _strMasterNodePrivKey, const s
return errorOut("ERROR: Empty masternodeaddr");
}

// Global params set
strMasterNodeAddr = _strMasterNodeAddr;

// Address parsing.
const CChainParams& params = Params();
int nPort = 0;
int nDefaultPort = params.GetDefaultPort();
std::string strHost;
SplitHostPort(strMasterNodeAddr, nPort, strHost);
SplitHostPort(_strMasterNodeAddr, nPort, strHost);

// Allow for the port number to be omitted here and just double check
// that if a port is supplied, it matches the required default port.
Expand All @@ -254,7 +251,7 @@ OperationResult initMasternode(const std::string& _strMasterNodePrivKey, const s
}
CService addrTest(LookupNumeric(strHost.c_str(), nPort));
if (!addrTest.IsValid()) {
return errorOut(strprintf(_("Invalid -masternodeaddr address: %s"), strMasterNodeAddr));
return errorOut(strprintf(_("Invalid -masternodeaddr address: %s"), _strMasterNodeAddr));
}

// Peer port needs to match the masternode public one for IPv4 and IPv6.
Expand Down
3 changes: 3 additions & 0 deletions src/budget/budgetmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ class CBudgetManager : public CValidationInterface
mutable RecursiveMutex cs_finalizedvotes;
mutable RecursiveMutex cs_votes;

// budget finalization
std::string strBudgetMode = "";

CBudgetManager() {}

void ClearSeen()
Expand Down
4 changes: 2 additions & 2 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1906,7 +1906,7 @@ bool AppInitMain()
}

//get the mode of budget voting for this masternode
strBudgetMode = gArgs.GetArg("-budgetvotemode", "auto");
g_budgetman.strBudgetMode = gArgs.GetArg("-budgetvotemode", "auto");

#ifdef ENABLE_WALLET
// !TODO: remove after complete transition to DMN
Expand Down Expand Up @@ -1940,7 +1940,7 @@ bool AppInitMain()
}

LogPrintf("fLiteMode %d\n", fLiteMode);
LogPrintf("Budget Mode %s\n", strBudgetMode.c_str());
LogPrintf("Budget Mode %s\n", g_budgetman.strBudgetMode.c_str());

threadGroup.create_thread(std::bind(&ThreadCheckMasternodes));

Expand Down
5 changes: 1 addition & 4 deletions src/pivxd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@
* Use the buttons <code>Namespaces</code>, <code>Classes</code> or <code>Files</code> at the top of the page to start navigating the code.
*/

static bool fDaemon;

void WaitForShutdown()
{
while (!ShutdownRequested()) {
Expand Down Expand Up @@ -127,8 +125,7 @@ bool AppInit(int argc, char* argv[])
}

#ifndef WIN32
fDaemon = gArgs.GetBoolArg("-daemon", false);
if (fDaemon) {
if (gArgs.GetBoolArg("-daemon", false)) {
fprintf(stdout, "PIVX server starting\n");

// Daemonize
Expand Down
4 changes: 0 additions & 4 deletions src/util/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,10 @@ const char * const PIVX_MASTERNODE_CONF_FILENAME = "masternode.conf";
// PIVX only features
// Masternode
std::atomic<bool> fMasterNode{false};
std::string strMasterNodeAddr = "";
bool fLiteMode = false;
// budget finalization
std::string strBudgetMode = "";

ArgsManager gArgs;

bool fDaemon = false;
CTranslationInterface translationInterface;

bool CheckDiskSpace(const fs::path& dir, uint64_t additional_bytes)
Expand Down
2 changes: 0 additions & 2 deletions src/util/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ extern const char * const DEFAULT_DEBUGLOGFILE;

extern std::atomic<bool> fMasterNode;
extern bool fLiteMode;
extern std::string strMasterNodeAddr;
extern std::string strBudgetMode;

extern CTranslationInterface translationInterface;

Expand Down

0 comments on commit 9c64f9b

Please sign in to comment.