7 #ifndef BITCOIN_VALIDATION_H 8 #define BITCOIN_VALIDATION_H 10 #if defined(HAVE_CONFIG_H) 34 #include <boost/unordered_map.hpp> 35 #include <boost/filesystem/path.hpp> 144 typedef boost::unordered_map<uint256, CBlockIndex*, BlockHasher>
BlockMap;
260 std::string
GetWarnings(
const std::string& strFor);
285 void FindFilesToPrune(std::set<int>& setFilesToPrune, uint64_t nPruneAfterHeight);
301 bool* pfMissingInputs,
bool fOverrideMempoolLimit=
false,
bool fRejectAbsurdFee=
false,
bool fDryRun=
false);
319 template<
typename Stream>
320 void Serialize(Stream& s,
int nType,
int nVersion)
const {
323 template<
typename Stream>
348 template<
typename Stream>
349 void Serialize(Stream& s,
int nType,
int nVersion)
const {
353 template<
typename Stream>
383 template<
typename Stream>
384 void Serialize(Stream& s,
int nType,
int nVersion)
const {
390 template<
typename Stream>
424 template <
typename Stream,
typename Operation>
425 inline void SerializationOp(Stream& s, Operation ser_action,
int nType,
int nVersion) {
464 template<
typename Stream>
465 void Serialize(Stream& s,
int nType,
int nVersion)
const {
476 template<
typename Stream>
489 uint256 txid,
size_t indexValue,
bool isSpending) {
522 template<
typename Stream>
523 void Serialize(Stream& s,
int nType,
int nVersion)
const {
527 template<
typename Stream>
556 template<
typename Stream>
557 void Serialize(Stream& s,
int nType,
int nVersion)
const {
562 template<
typename Stream>
592 template <
typename Stream,
typename Operation>
593 inline void SerializationOp(Stream& s, Operation ser_action,
int nType,
int nVersion) {
635 unsigned int flags,
bool cacheStore, std::vector<CScriptCheck> *pvChecks = NULL);
707 std::swap(
nIn, check.
nIn);
719 std::vector<std::pair<CAddressIndexKey, CAmount> > &addressIndex,
720 int start = 0,
int end = 0);
722 std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > &unspentOutputs);
769 template <
typename Stream,
typename Operation>
770 inline void SerializationOp(Stream& s, Operation ser_action,
int nType,
int nVersion) {
797 void AddBlock(
unsigned int nHeightIn, uint64_t nTimeIn) {
868 #endif // BITCOIN_VALIDATION_H
CAddressIndexIteratorHeightKey()
static const unsigned int DEFAULT_ANCESTOR_SIZE_LIMIT
static const int DEFAULT_SCRIPTCHECK_THREADS
bool CheckSequenceLocks(const CTransaction &tx, int flags, LockPoints *lp=NULL, bool useExistingLockPoints=false)
bool InvalidateBlock(CValidationState &state, const Consensus::Params &consensusParams, CBlockIndex *pindex)
static const unsigned int MAX_BLOCKFILE_SIZE
static const unsigned int DEFAULT_DESCENDANT_LIMIT
double ConvertBitsToDouble(unsigned int nBits)
CTimestampIndexKey(unsigned int time, uint256 hash)
void UpdateCoins(const CTransaction &tx, CValidationState &state, CCoinsViewCache &inputs, int nHeight)
boost::condition_variable CConditionVariable
static const bool DEFAULT_PERMIT_BAREMULTISIG
size_t GetSerializeSize(int nType, int nVersion) const
void AddBlock(unsigned int nHeightIn, uint64_t nTimeIn)
void Unserialize(Stream &s, int nType, int nVersion)
uint64_t nTimeLast
earliest time of block in file
void Serialize(Stream &s, int nType, int nVersion) const
static const unsigned int AVG_ADDRESS_BROADCAST_INTERVAL
enum ScriptError_t ScriptError
CScriptCheck(const CCoins &txFromIn, const CTransaction &txToIn, unsigned int nInIn, unsigned int nFlagsIn, bool cacheIn)
uint64_t nTimeFirst
highest height of block in file
uint8_t ser_readdata8(Stream &s)
CTimestampIndexIteratorKey()
CConditionVariable cvBlockChange
void Unserialize(Stream &s, int nType, int nVersion)
void Serialize(Stream &s, int nType, int nVersion) const
static const unsigned int AVG_LOCAL_ADDRESS_BROADCAST_INTERVAL
bool ContextualCheckBlockHeader(const CBlockHeader &block, CValidationState &state, CBlockIndex *pindexPrev)
bool WriteBlockToDisk(const CBlock &block, CDiskBlockPos &pos, const CMessageHeader::MessageStartChars &messageStart)
static const unsigned int DEFAULT_DIP0001_MIN_RELAY_TX_FEE
static const unsigned int REJECT_ALREADY_KNOWN
static const int64_t BLOCK_DOWNLOAD_TIMEOUT_BASE
CAddressIndexKey(unsigned int addressType, uint160 addressHash, int height, int blockindex, uint256 txid, size_t indexValue, bool isSpending)
CBlockIndex * pindexBestHeader
static const unsigned int MIN_BLOCKS_TO_KEEP
static const unsigned int DEFAULT_ANCESTOR_LIMIT
bool IsFinalTx(const CTransaction &tx, int nBlockHeight, int64_t nBlockTime)
void ReprocessBlocks(int nBlocks)
static const unsigned int REJECT_CONFLICT
static const unsigned int MAX_REJECT_MESSAGE_LENGTH
unsigned int nUndoSize
number of used bytes of block file
void ser_writedata32(Stream &s, uint32_t obj)
CBlockIndex * FindForkInGlobalIndex(const CChain &chain, const CBlockLocator &locator)
std::string ToString() const
CAddressIndexIteratorKey()
void SerializationOp(Stream &s, Operation ser_action, int nType, int nVersion)
bool GetTransaction(const uint256 &hash, CTransaction &tx, const Consensus::Params ¶ms, uint256 &hashBlock, bool fAllowSlow=false)
bool LoadExternalBlockFile(const CChainParams &chainparams, FILE *fileIn, CDiskBlockPos *dbp=NULL)
CCoinsViewCache * pcoinsTip
bool CheckTransaction(const CTransaction &tx, CValidationState &state)
CAddressIndexIteratorHeightKey(unsigned int addressType, uint160 addressHash, int height)
unsigned int GetLegacySigOpCount(const CTransaction &tx)
static const unsigned int DEFAULT_LIMITFREERELAY
CAddressUnspentValue(CAmount sats, CScript scriptPubKey, int height)
CAddressUnspentKey(unsigned int addressType, uint160 addressHash, uint256 txid, size_t indexValue)
bool ReconsiderBlock(CValidationState &state, CBlockIndex *pindex)
static const uint64_t nMinDiskSpace
void Unserialize(Stream &s, int nType, int nVersion)
size_t GetSerializeSize(int nType, int nVersion) const
bool ContextualCheckBlock(const CBlock &block, CValidationState &state, CBlockIndex *pindexPrev)
void Serialize(Stream &s, int nType, int nVersion) const
boost::filesystem::path GetBlockPosFilename(const CDiskBlockPos &pos, const char *prefix)
bool CheckFinalTx(const CTransaction &tx, int flags=-1)
static const bool DEFAULT_ADDRESSINDEX
static const unsigned int DEFAULT_MAX_ORPHAN_TRANSACTIONS
unsigned int nSize
number of blocks stored in file
bool GetSpentIndex(CSpentIndexKey &key, CSpentIndexValue &value)
static const unsigned int REJECT_INTERNAL
unsigned int nBytesPerSigOp
bool TestBlockValidity(CValidationState &state, const CChainParams &chainparams, const CBlock &block, CBlockIndex *pindexPrev, bool fCheckPOW=true, bool fCheckMerkleRoot=true)
bool ReadBlockFromDisk(CBlock &block, const CDiskBlockPos &pos, const Consensus::Params &consensusParams)
static const int64_t BLOCK_DOWNLOAD_TIMEOUT_PER_PEER
static const bool DEFAULT_ALERTS
static const unsigned int AVG_INVENTORY_BROADCAST_INTERVAL
static const bool DEFAULT_WHITELISTRELAY
size_t GetSerializeSize(int nType, int nVersion) const
ADD_SERIALIZE_METHODS
latest time of block in file
uint32_t ser_readdata32(Stream &s)
void swap(prevector< N, T, Size, Diff > &other)
static const unsigned int BLOCKFILE_CHUNK_SIZE
unsigned int nHeightLast
lowest height of block in file
void Serialize(Stream &s, int nType, int nVersion) const
bool ActivateBestChain(CValidationState &state, const CChainParams &chainparams, const CBlock *pblock=NULL)
static const int MAX_BLOCKS_IN_TRANSIT_PER_PEER
size_t GetSerializeSize(int nType, int nVersion) const
static const unsigned int DEFAULT_BYTES_PER_SIGOP
bool GetUTXOCoins(const COutPoint &outpoint, CCoins &coins)
bool SequenceLocks(const CTransaction &tx, int flags, std::vector< int > *prevHeights, const CBlockIndex &block)
static const unsigned int MAX_HEADERS_RESULTS
void swap(CScriptCheck &check)
const CTransaction * ptxTo
static const unsigned int UNDOFILE_CHUNK_SIZE
std::atomic< bool > fDIP0001ActiveAtTip
static const unsigned int DEFAULT_DESCENDANT_SIZE_LIMIT
static const unsigned int DEFAULT_MEMPOOL_EXPIRY
void SerializationOp(Stream &s, Operation ser_action, int nType, int nVersion)
bool TestLockPointValidity(const LockPoints *lp)
CDiskTxPos(const CDiskBlockPos &blockIn, unsigned int nTxOffsetIn)
std::string GetWarnings(const std::string &strFor)
ThresholdState VersionBitsTipState(const Consensus::Params ¶ms, Consensus::DeploymentPos pos)
void ser_writedata32be(Stream &s, uint32_t obj)
bool GetTimestampIndex(const unsigned int &high, const unsigned int &low, std::vector< uint256 > &hashes)
std::string FormatStateMessage(const CValidationState &state)
bool ConnectBlock(const CBlock &block, CValidationState &state, CBlockIndex *pindex, CCoinsViewCache &coins, bool fJustCheck=false)
bool ProcessNewBlock(const CChainParams &chainparams, const CBlock *pblock, bool fForceProcessing, const CDiskBlockPos *dbp, bool *fNewBlock)
void Serialize(Stream &s, int nType, int nVersion) const
bool InitBlockIndex(const CChainParams &chainparams)
static const unsigned int DATABASE_WRITE_INTERVAL
bool GetAddressUnspent(uint160 addressHash, int type, std::vector< std::pair< CAddressUnspentKey, CAddressUnspentValue > > &unspentOutputs)
int GetUTXOHeight(const COutPoint &outpoint)
void Serialize(Stream &s, int nType, int nVersion) const
bool DisconnectBlock(const CBlock &block, CValidationState &state, const CBlockIndex *pindex, CCoinsViewCache &coins, bool *pfClean=NULL)
bool GetBlockHash(uint256 &hashRet, int nBlockHeight=-1)
void UnlinkPrunedFiles(std::set< int > &setFilesToPrune)
static const bool DEFAULT_CHECKPOINTS_ENABLED
static const bool DEFAULT_ENABLE_REPLACEMENT
std::map< uint256, int64_t > mapRejectedBlocks
int32_t ComputeBlockVersion(const CBlockIndex *pindexPrev, const Consensus::Params ¶ms, bool fAssumeMasternodeIsUpgraded=false)
static const bool DEFAULT_TESTSAFEMODE
FILE * OpenBlockFile(const CDiskBlockPos &pos, bool fReadOnly=false)
void Unserialize(Stream &s, int nType, int nVersion)
bool CheckBlock(const CBlock &block, CValidationState &state, bool fCheckPOW=true, bool fCheckMerkleRoot=true)
CWaitableCriticalSection csBestBlock
void FindFilesToPrune(std::set< int > &setFilesToPrune, uint64_t nPruneAfterHeight)
void SerializationOp(Stream &s, Operation ser_action, int nType, int nVersion)
static const signed int DEFAULT_CHECKBLOCKS
boost::unordered_map< uint256, CBlockIndex *, BlockHasher > BlockMap
std::atomic< bool > fDIP0001WasLockedIn
bool CheckDiskSpace(uint64_t nAdditionalBytes=0)
static const bool DEFAULT_TIMESTAMPINDEX
uint32_t ser_readdata32be(Stream &s)
CAmount GetBlockSubsidy(int nBits, int nHeight, const Consensus::Params &consensusParams, bool fSuperblockPartOnly=false)
static const unsigned int MAX_BLOCKS_TO_ANNOUNCE
bool CheckInputs(const CTransaction &tx, CValidationState &state, const CCoinsViewCache &view, bool fScriptChecks, unsigned int flags, bool cacheStore, std::vector< CScriptCheck > *pvChecks=NULL)
CBlockIndex * InsertBlockIndex(uint256 hash)
size_t operator()(const uint256 &hash) const
CTimestampIndexIteratorKey(unsigned int time)
bool IsInitialBlockDownload()
bool VerifyDB(const CChainParams &chainparams, CCoinsView *coinsview, int nCheckLevel, int nCheckDepth)
size_t GetSerializeSize(int nType, int nVersion) const
static const unsigned int DEFAULT_BANSCORE_THRESHOLD
static const int DIP0001_PROTOCOL_VERSION
ScriptError GetScriptError() const
static const bool DEFAULT_SPENTINDEX
bool DisconnectBlocks(int blocks)
static const unsigned int BLOCK_STALLING_TIMEOUT
void Unserialize(Stream &s, int nType, int nVersion)
void Unserialize(Stream &s, int nType, int nVersion)
static const unsigned int DEFAULT_LEGACY_MIN_RELAY_TX_FEE
unsigned int nHeightFirst
number of used bytes in the undo file
static const uint64_t MIN_DISK_SPACE_FOR_BLOCK_FILES
int GetUTXOConfirmations(const COutPoint &outpoint)
static const unsigned int DATABASE_FLUSH_INTERVAL
int GetSpendHeight(const CCoinsViewCache &inputs)
size_t GetSerializeSize(int nType, int nVersion) const
uint64_t GetCheapHash() const
const std::string strMessageMagic
CAddressIndexIteratorKey(unsigned int addressType, uint160 addressHash)
bool GetAddressIndex(uint160 addressHash, int type, std::vector< std::pair< CAddressIndexKey, CAmount > > &addressIndex, int start=0, int end=0)
static const bool DEFAULT_RELAYPRIORITY
CAmount GetMasternodePayment(int nHeight, CAmount blockValue)
FILE * OpenUndoFile(const CDiskBlockPos &pos, bool fReadOnly=false)
void Serialize(Stream &s, int nType, int nVersion) const
static const bool DEFAULT_WHITELISTFORCERELAY
void Unserialize(Stream &s, int nType, int nVersion)
bool AcceptToMemoryPool(CTxMemPool &pool, CValidationState &state, const CTransaction &tx, bool fLimitFree, bool *pfMissingInputs, bool fOverrideMempoolLimit=false, bool fRejectAbsurdFee=false, bool fDryRun=false)
VersionBitsCache versionbitscache
CBlockTreeDB * pblocktree
unsigned int GetP2SHSigOpCount(const CTransaction &tx, const CCoinsViewCache &mapInputs)
static const bool DEFAULT_TXINDEX
static const unsigned int BLOCK_DOWNLOAD_WINDOW
static const unsigned int DEFAULT_CHECKLEVEL
void ser_writedata8(Stream &s, uint8_t obj)
static const int MAX_SCRIPTCHECK_THREADS
bool CheckBlockHeader(const CBlockHeader &block, CValidationState &state, bool fCheckPOW=true)
static const unsigned int REJECT_HIGHFEE
bool ProcessNewBlockHeaders(const std::vector< CBlockHeader > &block, CValidationState &state, const CChainParams &chainparams, CBlockIndex **ppindex=NULL)