Skip to content

Commit 1d9d314

Browse files
committed
Merge pull request #5696
691161d Consensus: Create consensus/consensus.h with some constants (jtimon)
2 parents 1623f6e + 691161d commit 1d9d314

File tree

12 files changed

+34
-16
lines changed

12 files changed

+34
-16
lines changed

src/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ BITCOIN_CORE_H = \
8787
coins.h \
8888
compat.h \
8989
compressor.h \
90+
consensus/consensus.h \
9091
consensus/params.h \
9192
core_io.h \
9293
wallet/db.h \

src/bitcoin-tx.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@
44

55
#include "base58.h"
66
#include "clientversion.h"
7-
#include "primitives/block.h" // for MAX_BLOCK_SIZE
8-
#include "primitives/transaction.h"
9-
#include "core_io.h"
107
#include "coins.h"
8+
#include "consensus/consensus.h"
9+
#include "core_io.h"
1110
#include "keystore.h"
11+
#include "primitives/transaction.h"
1212
#include "script/script.h"
1313
#include "script/sign.h"
1414
#include "ui_interface.h" // for _(...)
1515
#include "univalue/univalue.h"
1616
#include "util.h"
17-
#include "utilstrencodings.h"
1817
#include "utilmoneystr.h"
18+
#include "utilstrencodings.h"
1919

2020
#include <stdio.h>
2121

src/consensus/consensus.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright (c) 2009-2010 Satoshi Nakamoto
2+
// Copyright (c) 2009-2014 The Bitcoin Core developers
3+
// Distributed under the MIT software license, see the accompanying
4+
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
5+
6+
#ifndef BITCOIN_CONSENSUS_CONSENSUS_H
7+
#define BITCOIN_CONSENSUS_CONSENSUS_H
8+
9+
/** The maximum allowed size for a serialized block, in bytes (network rule) */
10+
static const unsigned int MAX_BLOCK_SIZE = 1000000;
11+
/** The maximum allowed number of signature check operations in a block (network rule) */
12+
static const unsigned int MAX_BLOCK_SIGOPS = MAX_BLOCK_SIZE/50;
13+
/** Coinbase transaction outputs can only be spent after this number of new blocks (network rule) */
14+
static const int COINBASE_MATURITY = 100;
15+
/** Threshold for nLockTime: below this value it is interpreted as block number, otherwise as UNIX timestamp. */
16+
static const unsigned int LOCKTIME_THRESHOLD = 500000000; // Tue Nov 5 00:53:20 1985 UTC
17+
18+
#endif // BITCOIN_CONSENSUS_CONSENSUS_H

src/main.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414
#include "chain.h"
1515
#include "chainparams.h"
1616
#include "coins.h"
17+
#include "consensus/consensus.h"
18+
#include "net.h"
1719
#include "primitives/block.h"
1820
#include "primitives/transaction.h"
19-
#include "net.h"
2021
#include "script/script.h"
2122
#include "script/sigcache.h"
2223
#include "script/standard.h"
@@ -53,8 +54,6 @@ static const unsigned int DEFAULT_BLOCK_MIN_SIZE = 0;
5354
static const unsigned int DEFAULT_BLOCK_PRIORITY_SIZE = 50000;
5455
/** The maximum size for transactions we're willing to relay/mine */
5556
static const unsigned int MAX_STANDARD_TX_SIZE = 100000;
56-
/** The maximum allowed number of signature check operations in a block (network rule) */
57-
static const unsigned int MAX_BLOCK_SIGOPS = MAX_BLOCK_SIZE/50;
5857
/** Maximum number of signature check operations in an IsStandard() P2SH script */
5958
static const unsigned int MAX_P2SH_SIGOPS = 15;
6059
/** 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
6766
static const unsigned int BLOCKFILE_CHUNK_SIZE = 0x1000000; // 16 MiB
6867
/** The pre-allocation chunk size for rev?????.dat files (since 0.8) */
6968
static const unsigned int UNDOFILE_CHUNK_SIZE = 0x100000; // 1 MiB
70-
/** Coinbase transaction outputs can only be spent after this number of new blocks (network rule) */
71-
static const int COINBASE_MATURITY = 100;
72-
/** Threshold for nLockTime: below this value it is interpreted as block number, otherwise as UNIX timestamp. */
73-
static const unsigned int LOCKTIME_THRESHOLD = 500000000; // Tue Nov 5 00:53:20 1985 UTC
7469
/** Maximum number of script-checking threads allowed */
7570
static const int MAX_SCRIPTCHECK_THREADS = 16;
7671
/** -par default (number of script-checking threads, 0 = auto) */

src/merkleblock.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include "merkleblock.h"
77

88
#include "hash.h"
9-
#include "primitives/block.h" // for MAX_BLOCK_SIZE
9+
#include "consensus/consensus.h"
1010
#include "utilstrencodings.h"
1111

1212
using namespace std;

src/miner.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include "amount.h"
99
#include "chainparams.h"
10+
#include "consensus/consensus.h"
1011
#include "hash.h"
1112
#include "main.h"
1213
#include "net.h"

src/primitives/block.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
#include "serialize.h"
1111
#include "uint256.h"
1212

13-
/** The maximum allowed size for a serialized block, in bytes (network rule) */
14-
static const unsigned int MAX_BLOCK_SIZE = 1000000;
15-
1613
/** Nodes collect new transactions into a block, hash them into a hash tree,
1714
* and scan through nonce values to make the block's hash satisfy proof-of-work
1815
* requirements. When they solve the proof-of-work, they broadcast the block

src/qt/transactiondesc.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@
1010
#include "transactionrecord.h"
1111

1212
#include "base58.h"
13+
#include "consensus/consensus.h"
1314
#include "main.h"
1415
#include "script/script.h"
1516
#include "timedata.h"
1617
#include "ui_interface.h"
1718
#include "util.h"
19+
#include "wallet/db.h"
1820
#include "wallet/wallet.h"
1921

2022
#include <stdint.h>

src/qt/transactionrecord.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "transactionrecord.h"
66

77
#include "base58.h"
8+
#include "consensus/consensus.h"
89
#include "main.h"
910
#include "timedata.h"
1011
#include "wallet/wallet.h"

src/rpcmining.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55

66
#include "amount.h"
77
#include "chainparams.h"
8+
#include "consensus/consensus.h"
89
#include "core_io.h"
910
#include "init.h"
10-
#include "net.h"
1111
#include "main.h"
1212
#include "miner.h"
13+
#include "net.h"
1314
#include "pow.h"
1415
#include "rpcserver.h"
1516
#include "util.h"

0 commit comments

Comments
 (0)