Auto merge of #2894 - per-gron:dont-export-unless-needed, r=str4d
Make some globals static that can be I wrote this patch as part of making a Bazel build system but it really is independent from that so I'm putting this as a separate PR. External linkage does not help and just encourages sloppy dependencies (ie using symbols only declared in a cpp file in some other cpp file) and can lead to weird issues when there are name collisions.
This commit is contained in:
commit
8ef1d333b5
|
@ -16,7 +16,7 @@ using namespace std;
|
||||||
|
|
||||||
static boost::uuids::random_generator uuidgen;
|
static boost::uuids::random_generator uuidgen;
|
||||||
|
|
||||||
std::map<OperationStatus, std::string> OperationStatusMap = {
|
static std::map<OperationStatus, std::string> OperationStatusMap = {
|
||||||
{OperationStatus::READY, "queued"},
|
{OperationStatus::READY, "queued"},
|
||||||
{OperationStatus::EXECUTING, "executing"},
|
{OperationStatus::EXECUTING, "executing"},
|
||||||
{OperationStatus::CANCELLED, "cancelled"},
|
{OperationStatus::CANCELLED, "cancelled"},
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
#include <boost/optional.hpp>
|
#include <boost/optional.hpp>
|
||||||
|
|
||||||
EhSolverCancelledException solver_cancelled;
|
static EhSolverCancelledException solver_cancelled;
|
||||||
|
|
||||||
template<unsigned int N, unsigned int K>
|
template<unsigned int N, unsigned int K>
|
||||||
int Equihash<N,K>::InitialiseState(eh_HashState& base_state)
|
int Equihash<N,K>::InitialiseState(eh_HashState& base_state)
|
||||||
|
|
11
src/main.cpp
11
src/main.cpp
|
@ -55,7 +55,7 @@ CCriticalSection cs_main;
|
||||||
BlockMap mapBlockIndex;
|
BlockMap mapBlockIndex;
|
||||||
CChain chainActive;
|
CChain chainActive;
|
||||||
CBlockIndex *pindexBestHeader = NULL;
|
CBlockIndex *pindexBestHeader = NULL;
|
||||||
int64_t nTimeBestReceived = 0;
|
static int64_t nTimeBestReceived = 0;
|
||||||
CWaitableCriticalSection csBestBlock;
|
CWaitableCriticalSection csBestBlock;
|
||||||
CConditionVariable cvBlockChange;
|
CConditionVariable cvBlockChange;
|
||||||
int nScriptCheckThreads = 0;
|
int nScriptCheckThreads = 0;
|
||||||
|
@ -1644,9 +1644,10 @@ bool IsInitialBlockDownload()
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool fLargeWorkForkFound = false;
|
static bool fLargeWorkForkFound = false;
|
||||||
bool fLargeWorkInvalidChainFound = false;
|
static bool fLargeWorkInvalidChainFound = false;
|
||||||
CBlockIndex *pindexBestForkTip = NULL, *pindexBestForkBase = NULL;
|
static CBlockIndex *pindexBestForkTip = NULL;
|
||||||
|
static CBlockIndex *pindexBestForkBase = NULL;
|
||||||
|
|
||||||
void CheckForkWarningConditions()
|
void CheckForkWarningConditions()
|
||||||
{
|
{
|
||||||
|
@ -6052,7 +6053,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class CMainCleanup
|
static class CMainCleanup
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CMainCleanup() {}
|
CMainCleanup() {}
|
||||||
|
|
|
@ -64,21 +64,21 @@ double AtomicTimer::rate(const AtomicCounter& count)
|
||||||
return duration > 0 ? (double)count.get() / duration : 0;
|
return duration > 0 ? (double)count.get() / duration : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
CCriticalSection cs_metrics;
|
static CCriticalSection cs_metrics;
|
||||||
|
|
||||||
boost::synchronized_value<int64_t> nNodeStartTime;
|
static boost::synchronized_value<int64_t> nNodeStartTime;
|
||||||
boost::synchronized_value<int64_t> nNextRefresh;
|
static boost::synchronized_value<int64_t> nNextRefresh;
|
||||||
AtomicCounter transactionsValidated;
|
AtomicCounter transactionsValidated;
|
||||||
AtomicCounter ehSolverRuns;
|
AtomicCounter ehSolverRuns;
|
||||||
AtomicCounter solutionTargetChecks;
|
AtomicCounter solutionTargetChecks;
|
||||||
AtomicCounter minedBlocks;
|
static AtomicCounter minedBlocks;
|
||||||
AtomicTimer miningTimer;
|
AtomicTimer miningTimer;
|
||||||
|
|
||||||
boost::synchronized_value<std::list<uint256>> trackedBlocks;
|
static boost::synchronized_value<std::list<uint256>> trackedBlocks;
|
||||||
|
|
||||||
boost::synchronized_value<std::list<std::string>> messageBox;
|
static boost::synchronized_value<std::list<std::string>> messageBox;
|
||||||
boost::synchronized_value<std::string> initMessage;
|
static boost::synchronized_value<std::string> initMessage;
|
||||||
bool loaded = false;
|
static bool loaded = false;
|
||||||
|
|
||||||
extern int64_t GetNetworkHashPS(int lookup, int height);
|
extern int64_t GetNetworkHashPS(int lookup, int height);
|
||||||
|
|
||||||
|
|
10
src/net.cpp
10
src/net.cpp
|
@ -83,10 +83,10 @@ CCriticalSection cs_mapRelay;
|
||||||
limitedmap<CInv, int64_t> mapAlreadyAskedFor(MAX_INV_SZ);
|
limitedmap<CInv, int64_t> mapAlreadyAskedFor(MAX_INV_SZ);
|
||||||
|
|
||||||
static deque<string> vOneShots;
|
static deque<string> vOneShots;
|
||||||
CCriticalSection cs_vOneShots;
|
static CCriticalSection cs_vOneShots;
|
||||||
|
|
||||||
set<CNetAddr> setservAddNodeAddresses;
|
static set<CNetAddr> setservAddNodeAddresses;
|
||||||
CCriticalSection cs_setservAddNodeAddresses;
|
static CCriticalSection cs_setservAddNodeAddresses;
|
||||||
|
|
||||||
vector<std::string> vAddedNodes;
|
vector<std::string> vAddedNodes;
|
||||||
CCriticalSection cs_vAddedNodes;
|
CCriticalSection cs_vAddedNodes;
|
||||||
|
@ -95,7 +95,7 @@ NodeId nLastNodeId = 0;
|
||||||
CCriticalSection cs_nLastNodeId;
|
CCriticalSection cs_nLastNodeId;
|
||||||
|
|
||||||
static CSemaphore *semOutbound = NULL;
|
static CSemaphore *semOutbound = NULL;
|
||||||
boost::condition_variable messageHandlerCondition;
|
static boost::condition_variable messageHandlerCondition;
|
||||||
|
|
||||||
// Signals for message handling
|
// Signals for message handling
|
||||||
static CNodeSignals g_signals;
|
static CNodeSignals g_signals;
|
||||||
|
@ -1806,7 +1806,7 @@ bool StopNode()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
class CNetCleanup
|
static class CNetCleanup
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CNetCleanup() {}
|
CNetCleanup() {}
|
||||||
|
|
|
@ -45,8 +45,10 @@ long long get_nsec_cpu_time()
|
||||||
return ts.tv_sec * 1000000000ll + ts.tv_nsec;
|
return ts.tv_sec * 1000000000ll + ts.tv_nsec;
|
||||||
}
|
}
|
||||||
|
|
||||||
long long start_time, last_time;
|
static long long start_time;
|
||||||
long long start_cpu_time, last_cpu_time;
|
static long long last_time;
|
||||||
|
static long long start_cpu_time;
|
||||||
|
static long long last_cpu_time;
|
||||||
|
|
||||||
void start_profiling()
|
void start_profiling()
|
||||||
{
|
{
|
||||||
|
@ -57,20 +59,20 @@ void start_profiling()
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<std::string, size_t> invocation_counts;
|
std::map<std::string, size_t> invocation_counts;
|
||||||
std::map<std::string, long long> enter_times;
|
static std::map<std::string, long long> enter_times;
|
||||||
std::map<std::string, long long> last_times;
|
std::map<std::string, long long> last_times;
|
||||||
std::map<std::string, long long> cumulative_times;
|
std::map<std::string, long long> cumulative_times;
|
||||||
//TODO: Instead of analogous maps for time and cpu_time, use a single struct-valued map
|
//TODO: Instead of analogous maps for time and cpu_time, use a single struct-valued map
|
||||||
std::map<std::string, long long> enter_cpu_times;
|
static std::map<std::string, long long> enter_cpu_times;
|
||||||
std::map<std::string, long long> last_cpu_times;
|
static std::map<std::string, long long> last_cpu_times;
|
||||||
std::map<std::pair<std::string, std::string>, long long> op_counts;
|
static std::map<std::pair<std::string, std::string>, long long> op_counts;
|
||||||
std::map<std::pair<std::string, std::string>, long long> cumulative_op_counts; // ((msg, data_point), value)
|
static std::map<std::pair<std::string, std::string>, long long> cumulative_op_counts; // ((msg, data_point), value)
|
||||||
// TODO: Convert op_counts and cumulative_op_counts from pair to structs
|
// TODO: Convert op_counts and cumulative_op_counts from pair to structs
|
||||||
size_t indentation = 0;
|
static size_t indentation = 0;
|
||||||
|
|
||||||
std::vector<std::string> block_names;
|
static std::vector<std::string> block_names;
|
||||||
|
|
||||||
std::list<std::pair<std::string, long long*> > op_data_points = {
|
static std::list<std::pair<std::string, long long*> > op_data_points = {
|
||||||
#ifdef PROFILE_OP_COUNTS
|
#ifdef PROFILE_OP_COUNTS
|
||||||
std::make_pair("Fradd", &Fr<default_ec_pp>::add_cnt),
|
std::make_pair("Fradd", &Fr<default_ec_pp>::add_cnt),
|
||||||
std::make_pair("Frsub", &Fr<default_ec_pp>::sub_cnt),
|
std::make_pair("Frsub", &Fr<default_ec_pp>::sub_cnt),
|
||||||
|
|
|
@ -125,7 +125,7 @@ void locking_callback(int mode, int i, const char* file, int line) NO_THREAD_SAF
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init
|
// Init
|
||||||
class CInit
|
static class CInit
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CInit()
|
CInit()
|
||||||
|
|
|
@ -24,8 +24,7 @@ namespace libzcash {
|
||||||
|
|
||||||
#include "zcash/circuit/gadget.tcc"
|
#include "zcash/circuit/gadget.tcc"
|
||||||
|
|
||||||
CCriticalSection cs_ParamsIO;
|
static CCriticalSection cs_ParamsIO;
|
||||||
CCriticalSection cs_LoadKeys;
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void saveToFile(const std::string path, T& obj) {
|
void saveToFile(const std::string path, T& obj) {
|
||||||
|
|
|
@ -216,7 +216,7 @@ ZCProof ZCProof::random_invalid()
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::once_flag init_public_params_once_flag;
|
static std::once_flag init_public_params_once_flag;
|
||||||
|
|
||||||
void initialize_curve_params()
|
void initialize_curve_params()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue