mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 04:22:55 +01:00
Make some globals in main non-public.
This means they are declared static, and their extern definition in main.h is removed. Also moved CBlockIndexWorkComparator to the .cpp file.
This commit is contained in:
parent
85eb2cef33
commit
caca6aa4eb
27
src/main.cpp
27
src/main.cpp
@ -33,8 +33,6 @@ unsigned int nTransactionsUpdated = 0;
|
|||||||
|
|
||||||
map<uint256, CBlockIndex*> mapBlockIndex;
|
map<uint256, CBlockIndex*> mapBlockIndex;
|
||||||
CChain chainActive;
|
CChain chainActive;
|
||||||
CBlockIndex *pindexBestInvalid;
|
|
||||||
set<CBlockIndex*, CBlockIndexWorkComparator> setBlockIndexValid; // may contain all CBlockIndex*'s that have validness >=BLOCK_VALID_TRANSACTIONS, and must contain those who aren't failed
|
|
||||||
int64 nTimeBestReceived = 0;
|
int64 nTimeBestReceived = 0;
|
||||||
int nScriptCheckThreads = 0;
|
int nScriptCheckThreads = 0;
|
||||||
bool fImporting = false;
|
bool fImporting = false;
|
||||||
@ -65,7 +63,28 @@ const string strMessageMagic = "Bitcoin Signed Message:\n";
|
|||||||
// Settings
|
// Settings
|
||||||
int64 nTransactionFee = 0;
|
int64 nTransactionFee = 0;
|
||||||
|
|
||||||
|
// Internal stuff
|
||||||
|
namespace {
|
||||||
|
struct CBlockIndexWorkComparator
|
||||||
|
{
|
||||||
|
bool operator()(CBlockIndex *pa, CBlockIndex *pb) {
|
||||||
|
if (pa->nChainWork > pb->nChainWork) return false;
|
||||||
|
if (pa->nChainWork < pb->nChainWork) return true;
|
||||||
|
|
||||||
|
if (pa->GetBlockHash() < pb->GetBlockHash()) return false;
|
||||||
|
if (pa->GetBlockHash() > pb->GetBlockHash()) return true;
|
||||||
|
|
||||||
|
return false; // identical blocks
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
CBlockIndex *pindexBestInvalid;
|
||||||
|
set<CBlockIndex*, CBlockIndexWorkComparator> setBlockIndexValid; // may contain all CBlockIndex*'s that have validness >=BLOCK_VALID_TRANSACTIONS, and must contain those who aren't failed
|
||||||
|
|
||||||
|
CCriticalSection cs_LastBlockFile;
|
||||||
|
CBlockFileInfo infoLastBlockFile;
|
||||||
|
int nLastBlockFile = 0;
|
||||||
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
@ -2694,10 +2713,6 @@ bool CheckDiskSpace(uint64 nAdditionalBytes)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
CCriticalSection cs_LastBlockFile;
|
|
||||||
CBlockFileInfo infoLastBlockFile;
|
|
||||||
int nLastBlockFile = 0;
|
|
||||||
|
|
||||||
FILE* OpenDiskFile(const CDiskBlockPos &pos, const char *prefix, bool fReadOnly)
|
FILE* OpenDiskFile(const CDiskBlockPos &pos, const char *prefix, bool fReadOnly)
|
||||||
{
|
{
|
||||||
if (pos.IsNull())
|
if (pos.IsNull())
|
||||||
|
20
src/main.h
20
src/main.h
@ -26,8 +26,6 @@ class CAddress;
|
|||||||
class CInv;
|
class CInv;
|
||||||
class CNode;
|
class CNode;
|
||||||
|
|
||||||
struct CBlockIndexWorkComparator;
|
|
||||||
|
|
||||||
/** The maximum allowed size for a serialized block, in bytes (network rule) */
|
/** The maximum allowed size for a serialized block, in bytes (network rule) */
|
||||||
static const unsigned int MAX_BLOCK_SIZE = 1000000;
|
static const unsigned int MAX_BLOCK_SIZE = 1000000;
|
||||||
/** The maximum size for mined blocks */
|
/** The maximum size for mined blocks */
|
||||||
@ -73,7 +71,6 @@ extern CScript COINBASE_FLAGS;
|
|||||||
|
|
||||||
extern CCriticalSection cs_main;
|
extern CCriticalSection cs_main;
|
||||||
extern std::map<uint256, CBlockIndex*> mapBlockIndex;
|
extern std::map<uint256, CBlockIndex*> mapBlockIndex;
|
||||||
extern std::set<CBlockIndex*, CBlockIndexWorkComparator> setBlockIndexValid;
|
|
||||||
extern unsigned int nTransactionsUpdated;
|
extern unsigned int nTransactionsUpdated;
|
||||||
extern uint64 nLastBlockTx;
|
extern uint64 nLastBlockTx;
|
||||||
extern uint64 nLastBlockSize;
|
extern uint64 nLastBlockSize;
|
||||||
@ -646,10 +643,6 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
extern CCriticalSection cs_LastBlockFile;
|
|
||||||
extern CBlockFileInfo infoLastBlockFile;
|
|
||||||
extern int nLastBlockFile;
|
|
||||||
|
|
||||||
enum BlockStatus {
|
enum BlockStatus {
|
||||||
BLOCK_VALID_UNKNOWN = 0,
|
BLOCK_VALID_UNKNOWN = 0,
|
||||||
BLOCK_VALID_HEADER = 1, // parsed, version ok, hash satisfies claimed PoW, 1 <= vtx count <= max, timestamp not in future
|
BLOCK_VALID_HEADER = 1, // parsed, version ok, hash satisfies claimed PoW, 1 <= vtx count <= max, timestamp not in future
|
||||||
@ -849,19 +842,6 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CBlockIndexWorkComparator
|
|
||||||
{
|
|
||||||
bool operator()(CBlockIndex *pa, CBlockIndex *pb) {
|
|
||||||
if (pa->nChainWork > pb->nChainWork) return false;
|
|
||||||
if (pa->nChainWork < pb->nChainWork) return true;
|
|
||||||
|
|
||||||
if (pa->GetBlockHash() < pb->GetBlockHash()) return false;
|
|
||||||
if (pa->GetBlockHash() > pb->GetBlockHash()) return true;
|
|
||||||
|
|
||||||
return false; // identical blocks
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** Used to marshal pointers into hashes for db storage. */
|
/** Used to marshal pointers into hashes for db storage. */
|
||||||
|
Loading…
Reference in New Issue
Block a user