Changeset View
Changeset View
Standalone View
Standalone View
src/chain.h
// Copyright (c) 2009-2010 Satoshi Nakamoto | // Copyright (c) 2009-2010 Satoshi Nakamoto | ||||
// Copyright (c) 2009-2016 The Bitcoin Core developers | // Copyright (c) 2009-2016 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#ifndef BITCOIN_CHAIN_H | #ifndef BITCOIN_CHAIN_H | ||||
#define BITCOIN_CHAIN_H | #define BITCOIN_CHAIN_H | ||||
#include "arith_uint256.h" | #include "arith_uint256.h" | ||||
#include "blockvalidity.h" | |||||
#include "consensus/params.h" | #include "consensus/params.h" | ||||
#include "diskblockpos.h" | #include "diskblockpos.h" | ||||
#include "pow.h" | #include "pow.h" | ||||
#include "primitives/block.h" | #include "primitives/block.h" | ||||
#include "tinyformat.h" | #include "tinyformat.h" | ||||
#include "uint256.h" | #include "uint256.h" | ||||
#include <unordered_map> | #include <unordered_map> | ||||
#include <vector> | #include <vector> | ||||
/** | /** | ||||
* Maximum amount of time that a block timestamp is allowed to exceed the | * Maximum amount of time that a block timestamp is allowed to exceed the | ||||
* current network-adjusted time before the block will be accepted. | * current network-adjusted time before the block will be accepted. | ||||
*/ | */ | ||||
static const int64_t MAX_FUTURE_BLOCK_TIME = 2 * 60 * 60; | static const int64_t MAX_FUTURE_BLOCK_TIME = 2 * 60 * 60; | ||||
/** | /** | ||||
* Timestamp window used as a grace period by code that compares external | * Timestamp window used as a grace period by code that compares external | ||||
* timestamps (such as timestamps passed to RPCs, or wallet key creation times) | * timestamps (such as timestamps passed to RPCs, or wallet key creation times) | ||||
* to block timestamps. This should be set at least as high as | * to block timestamps. This should be set at least as high as | ||||
* MAX_FUTURE_BLOCK_TIME. | * MAX_FUTURE_BLOCK_TIME. | ||||
*/ | */ | ||||
static const int64_t TIMESTAMP_WINDOW = MAX_FUTURE_BLOCK_TIME; | static const int64_t TIMESTAMP_WINDOW = MAX_FUTURE_BLOCK_TIME; | ||||
enum class BlockValidity : uint32_t { | |||||
/** | |||||
* Unused. | |||||
*/ | |||||
UNKNOWN = 0, | |||||
/** | |||||
* Parsed, version ok, hash satisfies claimed PoW, 1 <= vtx count <= max, | |||||
* timestamp not in future. | |||||
*/ | |||||
HEADER = 1, | |||||
/** | |||||
* All parent headers found, difficulty matches, timestamp >= median | |||||
* previous, checkpoint. Implies all parents are also at least TREE. | |||||
*/ | |||||
TREE = 2, | |||||
/** | |||||
* Only first tx is coinbase, 2 <= coinbase input script length <= 100, | |||||
* transactions valid, no duplicate txids, sigops, size, merkle root. | |||||
* Implies all parents are at least TREE but not necessarily TRANSACTIONS. | |||||
* When all parent blocks also have TRANSACTIONS, CBlockIndex::nChainTx will | |||||
* be set. | |||||
*/ | |||||
TRANSACTIONS = 3, | |||||
/** | |||||
* Outputs do not overspend inputs, no double spends, coinbase output ok, no | |||||
* immature coinbase spends, BIP30. | |||||
* Implies all parents are also at least CHAIN. | |||||
*/ | |||||
CHAIN = 4, | |||||
/** | |||||
* Scripts & signatures ok. Implies all parents are also at least SCRIPTS. | |||||
*/ | |||||
SCRIPTS = 5, | |||||
}; | |||||
struct BlockStatus { | struct BlockStatus { | ||||
private: | private: | ||||
uint32_t status; | uint32_t status; | ||||
explicit BlockStatus(uint32_t nStatusIn) : status(nStatusIn) {} | explicit BlockStatus(uint32_t nStatusIn) : status(nStatusIn) {} | ||||
static const uint32_t VALIDITY_MASK = 0x07; | static const uint32_t VALIDITY_MASK = 0x07; | ||||
▲ Show 20 Lines • Show All 471 Lines • Show Last 20 Lines |