Bitcoin ABC 0.32.4
P2P Digital Currency
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 ArgsManager;
14class Config;
15
16namespace node {
19 // Configuration parameters for the block size
23
24public:
25 static constexpr uint64_t COINBASE_RESERVED_SIZE{1000};
26 static constexpr uint64_t COINBASE_RESERVED_SIGCHECKS{100};
27
28 // Information on the current status of the block
29 uint64_t nBlockSize;
30 uint64_t nBlockTx;
33
34 struct Options {
35 Options();
39 };
40
41 BlockFitter(const Options &options);
42 BlockFitter(const Config &config);
43
45
47 void resetBlock();
48
50 void addTx(size_t txSize, int64_t txSigChecks, Amount txFee);
55 void removeTxUnchecked(size_t txSize, int64_t txSigChecks, Amount txFee);
56
58 bool testTxFits(uint64_t txSize, int64_t txSigChecks) const;
59
60 /* Check if the tx feerate is enough to be included in the block */
61 bool isBelowBlockMinFeeRate(const CFeeRate &txFeeRate) const;
62};
63
65void ApplyArgsManOptions(const ArgsManager &args, const Config &config,
66 BlockFitter::Options &options);
67} // namespace node
68
69#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:18
bool isBelowBlockMinFeeRate(const CFeeRate &txFeeRate) const
static constexpr uint64_t COINBASE_RESERVED_SIGCHECKS
Definition: blockfitter.h:26
uint64_t nMaxGeneratedBlockSigChecks
Definition: blockfitter.h:21
bool testTxFits(uint64_t txSize, int64_t txSigChecks) const
Test if a new Tx would "fit" in the block.
Definition: blockfitter.cpp:94
void resetBlock()
Clear the block's state and prepare for assembling a new block.
Definition: blockfitter.cpp:69
uint64_t nBlockSize
Definition: blockfitter.h:29
BlockFitter(const Options &options)
Definition: blockfitter.cpp:22
uint64_t getMaxGeneratedBlockSize() const
Definition: blockfitter.h:44
uint64_t nMaxGeneratedBlockSize
Definition: blockfitter.h:20
uint64_t nBlockTx
Definition: blockfitter.h:30
uint64_t nBlockSigChecks
Definition: blockfitter.h:31
void removeTxUnchecked(size_t txSize, int64_t txSigChecks, Amount txFee)
Remove accounting for this tx.
Definition: blockfitter.cpp:86
void addTx(size_t txSize, int64_t txSigChecks, Amount txFee)
Account for this tx.
Definition: blockfitter.cpp:79
CFeeRate blockMinFeeRate
Definition: blockfitter.h:22
static constexpr uint64_t COINBASE_RESERVED_SIZE
Definition: blockfitter.h:25
Definition: init.h:31
void ApplyArgsManOptions(const ArgsManager &args, const Config &config, BlockFitter::Options &options)
Apply options from ArgsManager to BlockFitter options.
Definition: blockfitter.cpp:40
Definition: amount.h:19