Bitcoin ABC 0.31.1
P2P Digital Currency
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
blockfitter.h
Go to the documentation of this file.
1// Copyright (c) 2025 The Bitcoin developers
2// Distributed under the MIT software license, see the accompanying
3// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5#ifndef BITCOIN_NODE_BLOCKFITTER_H
6#define BITCOIN_NODE_BLOCKFITTER_H
7
8#include <consensus/amount.h>
9#include <feerate.h>
10
11#include <cstdint>
12
13class Config;
14
15namespace node {
18 // Configuration parameters for the block size
22
23public:
24 static constexpr uint64_t COINBASE_RESERVED_SIZE{1000};
25 static constexpr uint64_t COINBASE_RESERVED_SIGCHECKS{100};
26
27 // Information on the current status of the block
28 uint64_t nBlockSize;
29 uint64_t nBlockTx;
32
33 struct Options {
34 Options();
38 };
39
40 BlockFitter(const Options &options);
41 BlockFitter(const Config &config);
42
44
46 void resetBlock();
47
49 void addTx(size_t txSize, int64_t txSigChecks, Amount txFee);
54 void removeTxUnchecked(size_t txSize, int64_t txSigChecks, Amount txFee);
55
57 bool testTxFits(uint64_t txSize, int64_t txSigChecks) const;
58
59 /* Check if the tx feerate is enough to be included in the block */
60 bool isBelowBlockMinFeeRate(const CFeeRate &txFeeRate) const;
61};
62} // namespace node
63
64#endif // BITCOIN_NODE_BLOCKFITTER_H
Fee rate in satoshis per kilobyte: Amount / kB.
Definition: feerate.h:21
Definition: config.h:19
Check for block limits when adding transactions.
Definition: blockfitter.h:17
bool isBelowBlockMinFeeRate(const CFeeRate &txFeeRate) const
static constexpr uint64_t COINBASE_RESERVED_SIGCHECKS
Definition: blockfitter.h:25
uint64_t nMaxGeneratedBlockSigChecks
Definition: blockfitter.h:20
bool testTxFits(uint64_t txSize, int64_t txSigChecks) const
Test if a new Tx would "fit" in the block.
Definition: blockfitter.cpp:91
void resetBlock()
Clear the block's state and prepare for assembling a new block.
Definition: blockfitter.cpp:66
uint64_t nBlockSize
Definition: blockfitter.h:28
BlockFitter(const Options &options)
Definition: blockfitter.cpp:22
uint64_t getMaxGeneratedBlockSize() const
Definition: blockfitter.h:43
uint64_t nMaxGeneratedBlockSize
Definition: blockfitter.h:19
uint64_t nBlockTx
Definition: blockfitter.h:29
uint64_t nBlockSigChecks
Definition: blockfitter.h:30
void removeTxUnchecked(size_t txSize, int64_t txSigChecks, Amount txFee)
Remove accounting for this tx.
Definition: blockfitter.cpp:83
void addTx(size_t txSize, int64_t txSigChecks, Amount txFee)
Account for this tx.
Definition: blockfitter.cpp:76
CFeeRate blockMinFeeRate
Definition: blockfitter.h:21
static constexpr uint64_t COINBASE_RESERVED_SIZE
Definition: blockfitter.h:24
Definition: init.h:31
Definition: amount.h:19