diff --git a/src/Makefile.am b/src/Makefile.am index 37184b628..72d79619b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -87,6 +87,7 @@ BITCOIN_CORE_H = \ coins.h \ compat.h \ compressor.h \ + consensus/consensus.h \ consensus/params.h \ core_io.h \ wallet/db.h \ diff --git a/src/bitcoin-tx.cpp b/src/bitcoin-tx.cpp index 78f5c2c4b..f1c1c0ff8 100644 --- a/src/bitcoin-tx.cpp +++ b/src/bitcoin-tx.cpp @@ -4,18 +4,18 @@ #include "base58.h" #include "clientversion.h" -#include "primitives/block.h" // for MAX_BLOCK_SIZE -#include "primitives/transaction.h" -#include "core_io.h" #include "coins.h" +#include "consensus/consensus.h" +#include "core_io.h" #include "keystore.h" +#include "primitives/transaction.h" #include "script/script.h" #include "script/sign.h" #include "ui_interface.h" // for _(...) #include "univalue/univalue.h" #include "util.h" -#include "utilstrencodings.h" #include "utilmoneystr.h" +#include "utilstrencodings.h" #include diff --git a/src/consensus/consensus.h b/src/consensus/consensus.h new file mode 100644 index 000000000..9c5b7d4ff --- /dev/null +++ b/src/consensus/consensus.h @@ -0,0 +1,18 @@ +// 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 = 1000000; +/** 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 + +#endif // BITCOIN_CONSENSUS_CONSENSUS_H diff --git a/src/main.h b/src/main.h index d34f6c30d..b0aec6662 100644 --- a/src/main.h +++ b/src/main.h @@ -14,9 +14,10 @@ #include "chain.h" #include "chainparams.h" #include "coins.h" +#include "consensus/consensus.h" +#include "net.h" #include "primitives/block.h" #include "primitives/transaction.h" -#include "net.h" #include "script/script.h" #include "script/sigcache.h" #include "script/standard.h" @@ -53,8 +54,6 @@ static const unsigned int DEFAULT_BLOCK_MIN_SIZE = 0; static const unsigned int DEFAULT_BLOCK_PRIORITY_SIZE = 50000; /** The maximum size for transactions we're willing to relay/mine */ static const unsigned int MAX_STANDARD_TX_SIZE = 100000; -/** The maximum allowed number of signature check operations in a block (network rule) */ -static const unsigned int MAX_BLOCK_SIGOPS = MAX_BLOCK_SIZE/50; /** 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 */ @@ -67,10 +66,6 @@ static const unsigned int MAX_BLOCKFILE_SIZE = 0x8000000; // 128 MiB 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 -/** 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 /** Maximum number of script-checking threads allowed */ static const int MAX_SCRIPTCHECK_THREADS = 16; /** -par default (number of script-checking threads, 0 = auto) */ diff --git a/src/merkleblock.cpp b/src/merkleblock.cpp index b51b002b9..c48d8cd50 100644 --- a/src/merkleblock.cpp +++ b/src/merkleblock.cpp @@ -6,7 +6,7 @@ #include "merkleblock.h" #include "hash.h" -#include "primitives/block.h" // for MAX_BLOCK_SIZE +#include "consensus/consensus.h" #include "utilstrencodings.h" using namespace std; diff --git a/src/miner.cpp b/src/miner.cpp index 3abd2d68e..56a2c5828 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -7,6 +7,7 @@ #include "amount.h" #include "chainparams.h" +#include "consensus/consensus.h" #include "hash.h" #include "main.h" #include "net.h" diff --git a/src/primitives/block.h b/src/primitives/block.h index c7ed6f723..59f46deb1 100644 --- a/src/primitives/block.h +++ b/src/primitives/block.h @@ -10,9 +10,6 @@ #include "serialize.h" #include "uint256.h" -/** The maximum allowed size for a serialized block, in bytes (network rule) */ -static const unsigned int MAX_BLOCK_SIZE = 1000000; - /** Nodes collect new transactions into a block, hash them into a hash tree, * and scan through nonce values to make the block's hash satisfy proof-of-work * requirements. When they solve the proof-of-work, they broadcast the block diff --git a/src/qt/transactiondesc.cpp b/src/qt/transactiondesc.cpp index 4a2c51477..721424943 100644 --- a/src/qt/transactiondesc.cpp +++ b/src/qt/transactiondesc.cpp @@ -10,11 +10,13 @@ #include "transactionrecord.h" #include "base58.h" +#include "consensus/consensus.h" #include "main.h" #include "script/script.h" #include "timedata.h" #include "ui_interface.h" #include "util.h" +#include "wallet/db.h" #include "wallet/wallet.h" #include diff --git a/src/qt/transactionrecord.cpp b/src/qt/transactionrecord.cpp index 9db5ad0fd..7f1db58e5 100644 --- a/src/qt/transactionrecord.cpp +++ b/src/qt/transactionrecord.cpp @@ -5,6 +5,7 @@ #include "transactionrecord.h" #include "base58.h" +#include "consensus/consensus.h" #include "main.h" #include "timedata.h" #include "wallet/wallet.h" diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index aba250ba4..24b865150 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -5,11 +5,12 @@ #include "amount.h" #include "chainparams.h" +#include "consensus/consensus.h" #include "core_io.h" #include "init.h" -#include "net.h" #include "main.h" #include "miner.h" +#include "net.h" #include "pow.h" #include "rpcserver.h" #include "util.h" diff --git a/src/txmempool.cpp b/src/txmempool.cpp index 85ea3f77b..d05e3c6ee 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -6,6 +6,7 @@ #include "txmempool.h" #include "clientversion.h" +#include "consensus/consensus.h" #include "main.h" #include "streams.h" #include "util.h" diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index f0ee83491..81a9932f3 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -8,6 +8,7 @@ #include "base58.h" #include "checkpoints.h" #include "coincontrol.h" +#include "consensus/consensus.h" #include "main.h" #include "net.h" #include "script/script.h"