Bitcoin ABC 0.34.5
P2P Digital Currency
Loading...
Searching...
No Matches
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
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 virtualbyte: Amount / vB the feerate is represented internally as FeeFrac.
Definition feerate.h:24
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.
void resetBlock()
Clear the block's state and prepare for assembling a new block.
uint64_t nBlockSize
Definition blockfitter.h:29
uint64_t getMaxGeneratedBlockSize() const
Definition blockfitter.h:44
uint64_t nMaxGeneratedBlockSize
Definition blockfitter.h:20
uint64_t nBlockSigChecks
Definition blockfitter.h:31
void removeTxUnchecked(size_t txSize, int64_t txSigChecks, Amount txFee)
Remove accounting for this tx.
void addTx(size_t txSize, int64_t txSigChecks, Amount txFee)
Account for this tx.
CFeeRate blockMinFeeRate
Definition blockfitter.h:22
static constexpr uint64_t COINBASE_RESERVED_SIZE
Definition blockfitter.h:25
std::optional< bilingual_str > ApplyArgsManOptions(const ArgsManager &argsman, const CChainParams &chainparams, MemPoolOptions &mempool_opts)
Overlay the options set in argsman on top of corresponding members in mempool_opts.
static constexpr Amount zero() noexcept
Definition amount.h:36