aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/chainparams.cpp9
-rw-r--r--src/chainparamsbase.cpp25
-rw-r--r--src/chainparamsbase.h9
-rw-r--r--src/core.h13
-rw-r--r--src/txmempool.h13
-rw-r--r--src/util.cpp12
6 files changed, 46 insertions, 35 deletions
diff --git a/src/chainparams.cpp b/src/chainparams.cpp
index f2a14b8293..dfb4c59d87 100644
--- a/src/chainparams.cpp
+++ b/src/chainparams.cpp
@@ -354,10 +354,13 @@ void SelectParams(CBaseChainParams::Network network) {
pCurrentParams = &Params(network);
}
-bool SelectParamsFromCommandLine() {
- if (!SelectBaseParamsFromCommandLine())
+bool SelectParamsFromCommandLine()
+{
+ CBaseChainParams::Network network = NetworkIdFromCommandLine();
+ if (network == CBaseChainParams::MAX_NETWORK_TYPES)
return false;
- SelectParams(BaseParams().NetworkID());
+ SelectBaseParams(network);
+ SelectParams(network);
return true;
}
diff --git a/src/chainparamsbase.cpp b/src/chainparamsbase.cpp
index e9d63197bd..5d9ec7927b 100644
--- a/src/chainparamsbase.cpp
+++ b/src/chainparamsbase.cpp
@@ -100,22 +100,27 @@ void SelectBaseParams(CBaseChainParams::Network network)
}
}
-bool SelectBaseParamsFromCommandLine()
+CBaseChainParams::Network NetworkIdFromCommandLine()
{
bool fRegTest = GetBoolArg("-regtest", false);
bool fTestNet = GetBoolArg("-testnet", false);
- if (fTestNet && fRegTest) {
+ if (fTestNet && fRegTest)
+ return CBaseChainParams::MAX_NETWORK_TYPES;
+ if (fRegTest)
+ return CBaseChainParams::REGTEST;
+ if (fTestNet)
+ return CBaseChainParams::TESTNET;
+ return CBaseChainParams::MAIN;
+}
+
+bool SelectBaseParamsFromCommandLine()
+{
+ CBaseChainParams::Network network = NetworkIdFromCommandLine();
+ if (network == CBaseChainParams::MAX_NETWORK_TYPES)
return false;
- }
- if (fRegTest) {
- SelectBaseParams(CBaseChainParams::REGTEST);
- } else if (fTestNet) {
- SelectBaseParams(CBaseChainParams::TESTNET);
- } else {
- SelectBaseParams(CBaseChainParams::MAIN);
- }
+ SelectBaseParams(network);
return true;
}
diff --git a/src/chainparamsbase.h b/src/chainparamsbase.h
index cc154cf501..911d1181ac 100644
--- a/src/chainparamsbase.h
+++ b/src/chainparamsbase.h
@@ -26,7 +26,6 @@ public:
const std::string& DataDir() const { return strDataDir; }
int RPCPort() const { return nRPCPort; }
- Network NetworkID() const { return networkID; }
protected:
CBaseChainParams() {}
@@ -46,7 +45,13 @@ const CBaseChainParams& BaseParams();
void SelectBaseParams(CBaseChainParams::Network network);
/**
- * Looks for -regtest or -testnet and then calls SelectParams as appropriate.
+ * Looks for -regtest or -testnet and returns the appropriate Network ID.
+ * Returns MAX_NETWORK_TYPES if an invalid combination is given.
+ */
+CBaseChainParams::Network NetworkIdFromCommandLine();
+
+/**
+ * Calls NetworkIdFromCommandLine() and then calls SelectParams as appropriate.
* Returns false if an invalid combination is given.
*/
bool SelectBaseParamsFromCommandLine();
diff --git a/src/core.h b/src/core.h
index a348293578..a024dad740 100644
--- a/src/core.h
+++ b/src/core.h
@@ -61,19 +61,6 @@ public:
std::string ToString() const;
};
-/** An inpoint - a combination of a transaction and an index n into its vin */
-class CInPoint
-{
-public:
- const CTransaction* ptx;
- uint32_t n;
-
- CInPoint() { SetNull(); }
- CInPoint(const CTransaction* ptxIn, uint32_t nIn) { ptx = ptxIn; n = nIn; }
- void SetNull() { ptx = NULL; n = (uint32_t) -1; }
- bool IsNull() const { return (ptx == NULL && n == (uint32_t) -1); }
-};
-
/** An input of a transaction. It contains the location of the previous
* transaction's output that it claims and a signature that matches the
* output's public key.
diff --git a/src/txmempool.h b/src/txmempool.h
index c63fd6f590..ad190eea9d 100644
--- a/src/txmempool.h
+++ b/src/txmempool.h
@@ -52,6 +52,19 @@ public:
class CMinerPolicyEstimator;
+/** An inpoint - a combination of a transaction and an index n into its vin */
+class CInPoint
+{
+public:
+ const CTransaction* ptx;
+ uint32_t n;
+
+ CInPoint() { SetNull(); }
+ CInPoint(const CTransaction* ptxIn, uint32_t nIn) { ptx = ptxIn; n = nIn; }
+ void SetNull() { ptx = NULL; n = (uint32_t) -1; }
+ bool IsNull() const { return (ptx == NULL && n == (uint32_t) -1); }
+};
+
/*
* CTxMemPool stores valid-according-to-the-current-best-chain
* transactions that may be included in the next block.
diff --git a/src/util.cpp b/src/util.cpp
index 632d0965bf..544ffc98b8 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -395,7 +395,8 @@ boost::filesystem::path GetDefaultDataDir()
#endif
}
-static boost::filesystem::path pathCached[CBaseChainParams::MAX_NETWORK_TYPES+1];
+static boost::filesystem::path pathCached;
+static boost::filesystem::path pathCachedNetSpecific;
static CCriticalSection csPathCached;
const boost::filesystem::path &GetDataDir(bool fNetSpecific)
@@ -404,10 +405,7 @@ const boost::filesystem::path &GetDataDir(bool fNetSpecific)
LOCK(csPathCached);
- int nNet = CBaseChainParams::MAX_NETWORK_TYPES;
- if (fNetSpecific) nNet = BaseParams().NetworkID();
-
- fs::path &path = pathCached[nNet];
+ fs::path &path = fNetSpecific ? pathCachedNetSpecific : pathCached;
// This can be called during exceptions by LogPrintf(), so we cache the
// value so we don't have to do memory allocations after that.
@@ -433,8 +431,8 @@ const boost::filesystem::path &GetDataDir(bool fNetSpecific)
void ClearDatadirCache()
{
- std::fill(&pathCached[0], &pathCached[CBaseChainParams::MAX_NETWORK_TYPES+1],
- boost::filesystem::path());
+ pathCached = boost::filesystem::path();
+ pathCachedNetSpecific = boost::filesystem::path();
}
boost::filesystem::path GetConfigFile()