Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Folm
committed
Mar 29, 2018
1 parent
7e37fbd
commit ee78fd8
Showing
23 changed files
with
318 additions
and
203 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// Copyright (c) 2009-2010 Satoshi Nakamoto | ||
// Copyright (c) 2009-2014 The Bitcoin Core developers | ||
// Distributed under the MIT software license, see the accompanying | ||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
|
||
#ifndef BITCOIN_CONSENSUS_CONSENSUS_H | ||
#define BITCOIN_CONSENSUS_CONSENSUS_H | ||
|
||
/** The maximum allowed size for a serialized block, in bytes (network rule) */ | ||
static const unsigned int MAX_BLOCK_SIZE = 4000000; | ||
/** The maximum allowed number of signature check operations in a block (network rule) */ | ||
static const unsigned int MAX_BLOCK_SIGOPS = MAX_BLOCK_SIZE/50; | ||
/** Coinbase transaction outputs can only be spent after this number of new blocks (network rule) */ | ||
static const int COINBASE_MATURITY = 100; | ||
/** Threshold for nLockTime: below this value it is interpreted as block number, otherwise as UNIX timestamp. */ | ||
static const unsigned int LOCKTIME_THRESHOLD = 500000000; // Tue Nov 5 00:53:20 1985 UTC | ||
|
||
/** Default for -blockmaxsize and -blockminsize, which control the range of sizes the mining code will create **/ | ||
static const unsigned int DEFAULT_BLOCK_MAX_SIZE = 750000; | ||
static const unsigned int DEFAULT_BLOCK_MIN_SIZE = 0; | ||
/** Default for -blockprioritysize, maximum space for zero/low-fee transactions **/ | ||
static const unsigned int DEFAULT_BLOCK_PRIORITY_SIZE = 50000; | ||
/** Default for accepting alerts from the P2P network. */ | ||
static const bool DEFAULT_ALERTS = true; | ||
/** The maximum size for transactions we're willing to relay/mine */ | ||
static const unsigned int MAX_STANDARD_TX_SIZE = 100000; | ||
/** Maximum number of signature check operations in an IsStandard() P2SH script */ | ||
static const unsigned int MAX_P2SH_SIGOPS = 15; | ||
/** The maximum number of sigops we're willing to relay/mine in a single tx */ | ||
static const unsigned int MAX_TX_SIGOPS = MAX_BLOCK_SIGOPS / 5; | ||
/** Default for -maxorphantx, maximum number of orphan transactions kept in memory */ | ||
static const unsigned int DEFAULT_MAX_ORPHAN_TRANSACTIONS = 100; | ||
/** The maximum size of a blk?????.dat file (since 0.8) */ | ||
static const unsigned int MAX_BLOCKFILE_SIZE = 0x8000000; // 128 MiB | ||
/** The pre-allocation chunk size for blk?????.dat files (since 0.8) */ | ||
static const unsigned int BLOCKFILE_CHUNK_SIZE = 0x1000000; // 16 MiB | ||
/** The pre-allocation chunk size for rev?????.dat files (since 0.8) */ | ||
static const unsigned int UNDOFILE_CHUNK_SIZE = 0x100000; // 1 MiB | ||
/** Maximum number of script-checking threads allowed */ | ||
static const int MAX_SCRIPTCHECK_THREADS = 16; | ||
/** -par default (number of script-checking threads, 0 = auto) */ | ||
static const int DEFAULT_SCRIPTCHECK_THREADS = 0; | ||
/** Number of blocks that can be requested at any given time from a single peer. */ | ||
static const int MAX_BLOCKS_IN_TRANSIT_PER_PEER = 16; | ||
/** Timeout in seconds during which a peer must stall block download progress before being disconnected. */ | ||
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; | ||
/** Time to wait (in seconds) between writing blockchain state to disk. */ | ||
static const unsigned int DATABASE_WRITE_INTERVAL = 3600; | ||
/** Maximum length of reject messages. */ | ||
static const unsigned int MAX_REJECT_MESSAGE_LENGTH = 111; | ||
|
||
static const bool DEFAULT_PEERBLOOMFILTERS = true; | ||
|
||
|
||
#endif // BITCOIN_CONSENSUS_CONSENSUS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// Copyright (c) 2009-2010 Satoshi Nakamoto | ||
// Copyright (c) 2009-2014 The Bitcoin Core developers | ||
// Distributed under the MIT software license, see the accompanying | ||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
|
||
#ifndef BITCOIN_CONSENSUS_VALIDATION_H | ||
#define BITCOIN_CONSENSUS_VALIDATION_H | ||
|
||
#include <string> | ||
|
||
/** "reject" message codes */ | ||
static const unsigned char REJECT_MALFORMED = 0x01; | ||
static const unsigned char REJECT_INVALID = 0x10; | ||
static const unsigned char REJECT_OBSOLETE = 0x11; | ||
static const unsigned char REJECT_DUPLICATE = 0x12; | ||
static const unsigned char REJECT_NONSTANDARD = 0x40; | ||
static const unsigned char REJECT_DUST = 0x41; | ||
static const unsigned char REJECT_INSUFFICIENTFEE = 0x42; | ||
static const unsigned char REJECT_CHECKPOINT = 0x43; | ||
/** Capture information about block/transaction validation */ | ||
class CValidationState | ||
{ | ||
private: | ||
enum mode_state { | ||
MODE_VALID, //! everything ok | ||
MODE_INVALID, //! network rule violation (DoS value may be set) | ||
MODE_ERROR, //! run-time error | ||
} mode; | ||
int nDoS; | ||
std::string strRejectReason; | ||
unsigned char chRejectCode; | ||
bool corruptionPossible; | ||
|
||
public: | ||
CValidationState() : mode(MODE_VALID), nDoS(0), chRejectCode(0), corruptionPossible(false) {} | ||
bool DoS(int level, bool ret = false, unsigned char chRejectCodeIn = 0, std::string strRejectReasonIn = "", bool corruptionIn = false) | ||
{ | ||
chRejectCode = chRejectCodeIn; | ||
strRejectReason = strRejectReasonIn; | ||
corruptionPossible = corruptionIn; | ||
if (mode == MODE_ERROR) | ||
return ret; | ||
nDoS += level; | ||
mode = MODE_INVALID; | ||
return ret; | ||
} | ||
bool Invalid(bool ret = false, | ||
unsigned char _chRejectCode = 0, | ||
std::string _strRejectReason = "") | ||
{ | ||
return DoS(0, ret, _chRejectCode, _strRejectReason); | ||
} | ||
bool Error(std::string strRejectReasonIn = "") | ||
{ | ||
if (mode == MODE_VALID) | ||
strRejectReason = strRejectReasonIn; | ||
mode = MODE_ERROR; | ||
return false; | ||
} | ||
bool IsValid() const | ||
{ | ||
return mode == MODE_VALID; | ||
} | ||
bool IsInvalid() const | ||
{ | ||
return mode == MODE_INVALID; | ||
} | ||
bool IsError() const | ||
{ | ||
return mode == MODE_ERROR; | ||
} | ||
bool IsInvalid(int& nDoSOut) const | ||
{ | ||
if (IsInvalid()) { | ||
nDoSOut = nDoS; | ||
return true; | ||
} | ||
return false; | ||
} | ||
bool CorruptionPossible() const | ||
{ | ||
return corruptionPossible; | ||
} | ||
unsigned char GetRejectCode() const { return chRejectCode; } | ||
std::string GetRejectReason() const { return strRejectReason; } | ||
}; | ||
#endif // BITCOIN_CONSENSUS_VALIDATION_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.