From b1d49924bbc4a3955411a37a89e1da1fd41908a4 Mon Sep 17 00:00:00 2001 From: furszy Date: Tue, 21 Sep 2021 19:17:59 -0300 Subject: [PATCH 1/3] Remove unneeded global strMasterNodeAddr --- src/activemasternode.cpp | 7 ++----- src/util/system.cpp | 1 - src/util/system.h | 1 - 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/activemasternode.cpp b/src/activemasternode.cpp index 59c712ce8bb9c..c32b4470ed7ea 100644 --- a/src/activemasternode.cpp +++ b/src/activemasternode.cpp @@ -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. @@ -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. diff --git a/src/util/system.cpp b/src/util/system.cpp index 93d44955c983c..6fefccb172e40 100644 --- a/src/util/system.cpp +++ b/src/util/system.cpp @@ -86,7 +86,6 @@ const char * const PIVX_MASTERNODE_CONF_FILENAME = "masternode.conf"; // PIVX only features // Masternode std::atomic fMasterNode{false}; -std::string strMasterNodeAddr = ""; bool fLiteMode = false; // budget finalization std::string strBudgetMode = ""; diff --git a/src/util/system.h b/src/util/system.h index 4f7d6ceb048d9..b2f740391901e 100644 --- a/src/util/system.h +++ b/src/util/system.h @@ -55,7 +55,6 @@ extern const char * const DEFAULT_DEBUGLOGFILE; extern std::atomic fMasterNode; extern bool fLiteMode; -extern std::string strMasterNodeAddr; extern std::string strBudgetMode; extern CTranslationInterface translationInterface; From 8796c89014d5ff7c052669d25f267ac7f17c1bbf Mon Sep 17 00:00:00 2001 From: furszy Date: Tue, 21 Sep 2021 19:20:10 -0300 Subject: [PATCH 2/3] Remove unneeded global fDaemon --- src/pivxd.cpp | 5 +---- src/util/system.cpp | 1 - 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/pivxd.cpp b/src/pivxd.cpp index 5d4139a28e24a..e8842911efaca 100644 --- a/src/pivxd.cpp +++ b/src/pivxd.cpp @@ -35,8 +35,6 @@ * Use the buttons Namespaces, Classes or Files at the top of the page to start navigating the code. */ -static bool fDaemon; - void WaitForShutdown() { while (!ShutdownRequested()) { @@ -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 diff --git a/src/util/system.cpp b/src/util/system.cpp index 6fefccb172e40..5a2418904aa2a 100644 --- a/src/util/system.cpp +++ b/src/util/system.cpp @@ -92,7 +92,6 @@ std::string strBudgetMode = ""; ArgsManager gArgs; -bool fDaemon = false; CTranslationInterface translationInterface; bool CheckDiskSpace(const fs::path& dir, uint64_t additional_bytes) From 5ab02bcddfe5d0081c967808f90d4c8aa4ed4eb2 Mon Sep 17 00:00:00 2001 From: furszy Date: Tue, 21 Sep 2021 19:23:43 -0300 Subject: [PATCH 3/3] Deglobalize strBudgetMode variable inside budget manager. --- src/budget/budgetmanager.h | 3 +++ src/init.cpp | 4 ++-- src/util/system.cpp | 2 -- src/util/system.h | 1 - 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/budget/budgetmanager.h b/src/budget/budgetmanager.h index 7c35ba3c2770c..ed6651a0035c2 100644 --- a/src/budget/budgetmanager.h +++ b/src/budget/budgetmanager.h @@ -53,6 +53,9 @@ class CBudgetManager : public CValidationInterface mutable RecursiveMutex cs_finalizedvotes; mutable RecursiveMutex cs_votes; + // budget finalization + std::string strBudgetMode = ""; + CBudgetManager() {} void ClearSeen() diff --git a/src/init.cpp b/src/init.cpp index fb13d63e36117..e7ad54e3fbfd2 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -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 @@ -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)); diff --git a/src/util/system.cpp b/src/util/system.cpp index 5a2418904aa2a..0a8d29781da3c 100644 --- a/src/util/system.cpp +++ b/src/util/system.cpp @@ -87,8 +87,6 @@ const char * const PIVX_MASTERNODE_CONF_FILENAME = "masternode.conf"; // Masternode std::atomic fMasterNode{false}; bool fLiteMode = false; -// budget finalization -std::string strBudgetMode = ""; ArgsManager gArgs; diff --git a/src/util/system.h b/src/util/system.h index b2f740391901e..3bbd965df9e75 100644 --- a/src/util/system.h +++ b/src/util/system.h @@ -55,7 +55,6 @@ extern const char * const DEFAULT_DEBUGLOGFILE; extern std::atomic fMasterNode; extern bool fLiteMode; -extern std::string strBudgetMode; extern CTranslationInterface translationInterface;