|
|
@ -72,9 +72,17 @@ static const int MAX_SCRIPTCHECK_THREADS = 16; |
|
|
|
/** -par default (number of script-checking threads, 0 = auto) */ |
|
|
|
/** -par default (number of script-checking threads, 0 = auto) */ |
|
|
|
static const int DEFAULT_SCRIPTCHECK_THREADS = 0; |
|
|
|
static const int DEFAULT_SCRIPTCHECK_THREADS = 0; |
|
|
|
/** Number of blocks that can be requested at any given time from a single peer. */ |
|
|
|
/** Number of blocks that can be requested at any given time from a single peer. */ |
|
|
|
static const int MAX_BLOCKS_IN_TRANSIT_PER_PEER = 128; |
|
|
|
static const int MAX_BLOCKS_IN_TRANSIT_PER_PEER = 16; |
|
|
|
/** Timeout in seconds before considering a block download peer unresponsive. */ |
|
|
|
/** Timeout in seconds during which a peer must stall block download progress before being disconnected. */ |
|
|
|
static const unsigned int BLOCK_DOWNLOAD_TIMEOUT = 60; |
|
|
|
static const unsigned int BLOCK_STALLING_TIMEOUT = 2; |
|
|
|
|
|
|
|
/** Number of headers sent in one getheaders result. We rely on the assumption that if a peer sends
|
|
|
|
|
|
|
|
* less than this number, we reached their tip. Changing this value is a protocol upgrade. */ |
|
|
|
|
|
|
|
static const unsigned int MAX_HEADERS_RESULTS = 2000; |
|
|
|
|
|
|
|
/** Size of the "block download window": how far ahead of our current height do we fetch?
|
|
|
|
|
|
|
|
* Larger windows tolerate larger download speed differences between peer, but increase the potential |
|
|
|
|
|
|
|
* degree of disordering of blocks on disk (which make reindexing and in the future perhaps pruning |
|
|
|
|
|
|
|
* harder). We'll probably want to make this a per-peer adaptive value at some point. */ |
|
|
|
|
|
|
|
static const unsigned int BLOCK_DOWNLOAD_WINDOW = 1024; |
|
|
|
|
|
|
|
|
|
|
|
/** "reject" message codes **/ |
|
|
|
/** "reject" message codes **/ |
|
|
|
static const unsigned char REJECT_MALFORMED = 0x01; |
|
|
|
static const unsigned char REJECT_MALFORMED = 0x01; |
|
|
@ -110,6 +118,9 @@ extern bool fIsBareMultisigStd; |
|
|
|
extern unsigned int nCoinCacheSize; |
|
|
|
extern unsigned int nCoinCacheSize; |
|
|
|
extern CFeeRate minRelayTxFee; |
|
|
|
extern CFeeRate minRelayTxFee; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Best header we've seen so far (used for getheaders queries' starting points).
|
|
|
|
|
|
|
|
extern CBlockIndex *pindexBestHeader; |
|
|
|
|
|
|
|
|
|
|
|
// Minimum disk space required - used in CheckDiskSpace()
|
|
|
|
// Minimum disk space required - used in CheckDiskSpace()
|
|
|
|
static const uint64_t nMinDiskSpace = 52428800; |
|
|
|
static const uint64_t nMinDiskSpace = 52428800; |
|
|
|
|
|
|
|
|
|
|
@ -137,8 +148,6 @@ void RegisterNodeSignals(CNodeSignals& nodeSignals); |
|
|
|
/** Unregister a network node */ |
|
|
|
/** Unregister a network node */ |
|
|
|
void UnregisterNodeSignals(CNodeSignals& nodeSignals); |
|
|
|
void UnregisterNodeSignals(CNodeSignals& nodeSignals); |
|
|
|
|
|
|
|
|
|
|
|
void PushGetBlocks(CNode* pnode, CBlockIndex* pindexBegin, uint256 hashEnd); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Process an incoming block */ |
|
|
|
/** Process an incoming block */ |
|
|
|
bool ProcessBlock(CValidationState &state, CNode* pfrom, CBlock* pblock, CDiskBlockPos *dbp = NULL); |
|
|
|
bool ProcessBlock(CValidationState &state, CNode* pfrom, CBlock* pblock, CDiskBlockPos *dbp = NULL); |
|
|
|
/** Check whether enough disk space is available for an incoming block */ |
|
|
|
/** Check whether enough disk space is available for an incoming block */ |
|
|
@ -193,6 +202,8 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa |
|
|
|
struct CNodeStateStats { |
|
|
|
struct CNodeStateStats { |
|
|
|
int nMisbehavior; |
|
|
|
int nMisbehavior; |
|
|
|
int nSyncHeight; |
|
|
|
int nSyncHeight; |
|
|
|
|
|
|
|
int nCommonHeight; |
|
|
|
|
|
|
|
std::vector<int> vHeightInFlight; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
struct CDiskTxPos : public CDiskBlockPos |
|
|
|
struct CDiskTxPos : public CDiskBlockPos |
|
|
@ -439,9 +450,6 @@ bool DisconnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex |
|
|
|
// Apply the effects of this block (with given index) on the UTXO set represented by coins
|
|
|
|
// Apply the effects of this block (with given index) on the UTXO set represented by coins
|
|
|
|
bool ConnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex, CCoinsViewCache& coins, bool fJustCheck = false); |
|
|
|
bool ConnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex, CCoinsViewCache& coins, bool fJustCheck = false); |
|
|
|
|
|
|
|
|
|
|
|
// Add this block to the block index, and if necessary, switch the active block chain to this
|
|
|
|
|
|
|
|
bool AddToBlockIndex(CBlock& block, CValidationState& state, const CDiskBlockPos& pos); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Context-independent validity checks
|
|
|
|
// Context-independent validity checks
|
|
|
|
bool CheckBlockHeader(const CBlockHeader& block, CValidationState& state, bool fCheckPOW = true); |
|
|
|
bool CheckBlockHeader(const CBlockHeader& block, CValidationState& state, bool fCheckPOW = true); |
|
|
|
bool CheckBlock(const CBlock& block, CValidationState& state, bool fCheckPOW = true, bool fCheckMerkleRoot = true); |
|
|
|
bool CheckBlock(const CBlock& block, CValidationState& state, bool fCheckPOW = true, bool fCheckMerkleRoot = true); |
|
|
@ -449,7 +457,7 @@ bool CheckBlock(const CBlock& block, CValidationState& state, bool fCheckPOW = t |
|
|
|
// Store block on disk
|
|
|
|
// Store block on disk
|
|
|
|
// if dbp is provided, the file is known to already reside on disk
|
|
|
|
// if dbp is provided, the file is known to already reside on disk
|
|
|
|
bool AcceptBlock(CBlock& block, CValidationState& state, CBlockIndex **pindex, CDiskBlockPos* dbp = NULL); |
|
|
|
bool AcceptBlock(CBlock& block, CValidationState& state, CBlockIndex **pindex, CDiskBlockPos* dbp = NULL); |
|
|
|
bool AcceptBlockHeader(CBlockHeader& block, CValidationState& state, CBlockIndex **ppindex= NULL); |
|
|
|
bool AcceptBlockHeader(const CBlockHeader& block, CValidationState& state, CBlockIndex **ppindex= NULL); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|