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 "consensus/params.h" | #include "consensus/params.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; | ||||
struct CDiskBlockPos { | |||||
int nFile; | |||||
unsigned int nPos; | |||||
ADD_SERIALIZE_METHODS; | |||||
template <typename Stream, typename Operation> | |||||
inline void SerializationOp(Stream &s, Operation ser_action) { | |||||
READWRITE(VARINT(nFile)); | |||||
READWRITE(VARINT(nPos)); | |||||
} | |||||
CDiskBlockPos() { SetNull(); } | |||||
CDiskBlockPos(int nFileIn, unsigned int nPosIn) { | |||||
nFile = nFileIn; | |||||
nPos = nPosIn; | |||||
} | |||||
friend bool operator==(const CDiskBlockPos &a, const CDiskBlockPos &b) { | |||||
return (a.nFile == b.nFile && a.nPos == b.nPos); | |||||
} | |||||
friend bool operator!=(const CDiskBlockPos &a, const CDiskBlockPos &b) { | |||||
return !(a == b); | |||||
} | |||||
void SetNull() { | |||||
nFile = -1; | |||||
nPos = 0; | |||||
} | |||||
bool IsNull() const { return (nFile == -1); } | |||||
std::string ToString() const { | |||||
return strprintf("CBlockDiskPos(nFile=%i, nPos=%i)", nFile, nPos); | |||||
} | |||||
}; | |||||
enum class BlockValidity : uint32_t { | enum class BlockValidity : uint32_t { | ||||
/** | /** | ||||
* Unused. | * Unused. | ||||
*/ | */ | ||||
UNKNOWN = 0, | UNKNOWN = 0, | ||||
/** | /** | ||||
* Parsed, version ok, hash satisfies claimed PoW, 1 <= vtx count <= max, | * Parsed, version ok, hash satisfies claimed PoW, 1 <= vtx count <= max, | ||||
▲ Show 20 Lines • Show All 511 Lines • Show Last 20 Lines |