diff --git a/src/Makefile.am b/src/Makefile.am --- a/src/Makefile.am +++ b/src/Makefile.am @@ -93,6 +93,7 @@ blockencodings.h \ blockfileinfo.h \ blockindexworkcomparator.h \ + blockvalidity.h \ cashaddr.h \ cashaddrenc.h \ chain.h \ diff --git a/src/blockvalidity.h b/src/blockvalidity.h new file mode 100644 --- /dev/null +++ b/src/blockvalidity.h @@ -0,0 +1,50 @@ +// Copyright (c) 2018 The Bitcoin developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_BLOCKVALIDITY_H +#define BITCOIN_BLOCKVALIDITY_H + +#include + +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, +}; + +#endif // BITCOIN_BLOCKVALIDITY_H diff --git a/src/chain.h b/src/chain.h --- a/src/chain.h +++ b/src/chain.h @@ -7,6 +7,7 @@ #define BITCOIN_CHAIN_H #include "arith_uint256.h" +#include "blockvalidity.h" #include "consensus/params.h" #include "diskblockpos.h" #include "pow.h" @@ -31,46 +32,6 @@ */ 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 { private: uint32_t status; diff --git a/src/net_processing.cpp b/src/net_processing.cpp --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -8,6 +8,7 @@ #include "addrman.h" #include "arith_uint256.h" #include "blockencodings.h" +#include "blockvalidity.h" #include "chainparams.h" #include "config.h" #include "consensus/validation.h" diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -5,6 +5,7 @@ #include "rpc/mining.h" #include "amount.h" +#include "blockvalidity.h" #include "chain.h" #include "chainparams.h" #include "config.h" diff --git a/src/test/blockindex_tests.cpp b/src/test/blockindex_tests.cpp --- a/src/test/blockindex_tests.cpp +++ b/src/test/blockindex_tests.cpp @@ -2,6 +2,7 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. +#include "blockvalidity.h" #include "chain.h" #include "diskblockpos.h" #include "uint256.h" diff --git a/src/test/blockstatus_tests.cpp b/src/test/blockstatus_tests.cpp --- a/src/test/blockstatus_tests.cpp +++ b/src/test/blockstatus_tests.cpp @@ -2,6 +2,7 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. +#include "blockvalidity.h" #include "chain.h" #include "test/test_bitcoin.h" diff --git a/src/validation.h b/src/validation.h --- a/src/validation.h +++ b/src/validation.h @@ -16,6 +16,7 @@ #include "chain.h" #include "coins.h" #include "consensus/consensus.h" +#include "diskblockpos.h" #include "fs.h" #include "protocol.h" // For CMessageHeader::MessageMagic #include "script/script_error.h" diff --git a/src/validation.cpp b/src/validation.cpp --- a/src/validation.cpp +++ b/src/validation.cpp @@ -8,6 +8,7 @@ #include "arith_uint256.h" #include "blockindexworkcomparator.h" +#include "blockvalidity.h" #include "chainparams.h" #include "checkpoints.h" #include "checkqueue.h"