2013-07-31 15:43:35 +02:00
|
|
|
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
2023-08-16 19:27:31 +02:00
|
|
|
// Copyright (c) 2009-2020 The Bitcoin Core developers
|
2014-12-13 05:09:33 +01:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
2013-07-31 15:43:35 +02:00
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
2013-04-13 07:13:08 +02:00
|
|
|
|
2013-07-31 15:43:35 +02:00
|
|
|
#ifndef BITCOIN_MINER_H
|
|
|
|
#define BITCOIN_MINER_H
|
|
|
|
|
2020-03-19 23:46:56 +01:00
|
|
|
#include <primitives/block.h>
|
|
|
|
#include <txmempool.h>
|
2014-10-12 05:26:42 +02:00
|
|
|
|
2016-06-13 11:27:11 +02:00
|
|
|
#include <memory>
|
2022-10-15 22:11:49 +02:00
|
|
|
#include <optional>
|
2019-02-15 14:56:43 +01:00
|
|
|
#include <stdint.h>
|
|
|
|
|
2017-09-05 22:25:42 +02:00
|
|
|
#include <boost/multi_index_container.hpp>
|
|
|
|
#include <boost/multi_index/ordered_index.hpp>
|
2013-04-13 07:13:08 +02:00
|
|
|
|
|
|
|
class CBlockIndex;
|
2015-04-10 12:49:01 +02:00
|
|
|
class CChainParams;
|
Backport Bitcoin PR#8085: p2p: Begin encapsulation (#1537)
* net: move CBanDB and CAddrDB out of net.h/cpp
This will eventually solve a circular dependency
* net: Create CConnman to encapsulate p2p connections
* net: Move socket binding into CConnman
* net: move OpenNetworkConnection into CConnman
* net: move ban and addrman functions into CConnman
* net: Add oneshot functions to CConnman
* net: move added node functions to CConnman
* net: Add most functions needed for vNodes to CConnman
* net: handle nodesignals in CConnman
* net: Pass CConnection to wallet rather than using the global
* net: Add rpc error for missing/disabled p2p functionality
* net: Pass CConnman around as needed
* gui: add NodeID to the peer table
* net: create generic functor accessors and move vNodes to CConnman
* net: move whitelist functions into CConnman
* net: move nLastNodeId to CConnman
* net: move nLocalHostNonce to CConnman
This behavior seems to have been quite racy and broken.
Move nLocalHostNonce into CNode, and check received nonces against all
non-fully-connected nodes. If there's a match, assume we've connected
to ourself.
* net: move messageHandlerCondition to CConnman
* net: move send/recv statistics to CConnman
* net: move SendBufferSize/ReceiveFloodSize to CConnman
* net: move nLocalServices/nRelevantServices to CConnman
These are in-turn passed to CNode at connection time. This allows us to offer
different services to different peers (or test the effects of doing so).
* net: move semOutbound and semMasternodeOutbound to CConnman
* net: SocketSendData returns written size
* net: move max/max-outbound to CConnman
* net: Pass best block known height into CConnman
CConnman then passes the current best height into CNode at creation time.
This way CConnman/CNode have no dependency on main for height, and the signals
only move in one direction.
This also helps to prevent identity leakage a tiny bit. Before this change, an
attacker could theoretically make 2 connections on different interfaces. They
would connect fully on one, and only establish the initial connection on the
other. Once they receive a new block, they would relay it to your first
connection, and immediately commence the version handshake on the second. Since
the new block height is reflected immediately, they could attempt to learn
whether the two connections were correlated.
This is, of course, incredibly unlikely to work due to the small timings
involved and receipt from other senders. But it doesn't hurt to lock-in
nBestHeight at the time of connection, rather than letting the remote choose
the time.
* net: pass CClientUIInterface into CConnman
* net: Drop StartNode/StopNode and use CConnman directly
* net: Introduce CConnection::Options to avoid passing so many params
* net: add nSendBufferMaxSize/nReceiveFloodSize to CConnection::Options
* net: move vNodesDisconnected into CConnman
* Made the ForEachNode* functions in src/net.cpp more pragmatic and self documenting
* Convert ForEachNode* functions to take a templated function argument rather than a std::function to eliminate std::function overhead
* net: move MAX_FEELER_CONNECTIONS into connman
2017-07-21 11:35:19 +02:00
|
|
|
class CConnman;
|
2024-02-28 17:50:48 +01:00
|
|
|
class CCreditPoolManager;
|
2024-03-15 16:40:54 +01:00
|
|
|
class CDeterministicMNManager;
|
2023-12-05 09:32:18 +01:00
|
|
|
class CEvoDB;
|
2024-03-14 04:29:04 +01:00
|
|
|
class CChainstateHelper;
|
2024-02-29 15:52:08 +01:00
|
|
|
class CMNHFManager;
|
2013-04-13 07:13:08 +02:00
|
|
|
class CScript;
|
2023-07-30 03:23:02 +02:00
|
|
|
struct LLMQContext;
|
2024-03-02 22:26:00 +01:00
|
|
|
struct NodeContext;
|
2016-06-13 11:27:11 +02:00
|
|
|
|
2015-04-16 10:32:47 +02:00
|
|
|
namespace Consensus { struct Params; };
|
2022-09-22 13:14:48 +02:00
|
|
|
namespace llmq {
|
|
|
|
class CChainLocksHandler;
|
|
|
|
class CInstantSendManager;
|
|
|
|
class CQuorumBlockProcessor;
|
|
|
|
} // namespace llmq
|
2013-07-31 15:43:35 +02:00
|
|
|
|
2015-06-27 21:21:41 +02:00
|
|
|
static const bool DEFAULT_PRINTPRIORITY = false;
|
|
|
|
|
2014-10-12 05:26:42 +02:00
|
|
|
struct CBlockTemplate
|
|
|
|
{
|
|
|
|
CBlock block;
|
|
|
|
std::vector<CAmount> vTxFees;
|
|
|
|
std::vector<int64_t> vTxSigOps;
|
2018-08-11 00:28:30 +02:00
|
|
|
uint32_t nPrevBits; // nBits of previous block (for subsidy calculation)
|
2018-08-14 11:58:38 +02:00
|
|
|
std::vector<CTxOut> voutMasternodePayments; // masternode payment
|
|
|
|
std::vector<CTxOut> voutSuperblockPayments; // superblock payment
|
2014-10-12 05:26:42 +02:00
|
|
|
};
|
2014-05-10 14:54:20 +02:00
|
|
|
|
2016-06-16 18:42:45 +02:00
|
|
|
// Container for tracking updates to ancestor feerate as we include (parent)
|
|
|
|
// transactions in a block
|
|
|
|
struct CTxMemPoolModifiedEntry {
|
2017-08-17 22:59:56 +02:00
|
|
|
explicit CTxMemPoolModifiedEntry(CTxMemPool::txiter entry)
|
2016-06-16 18:42:45 +02:00
|
|
|
{
|
|
|
|
iter = entry;
|
|
|
|
nSizeWithAncestors = entry->GetSizeWithAncestors();
|
|
|
|
nModFeesWithAncestors = entry->GetModFeesWithAncestors();
|
|
|
|
nSigOpCountWithAncestors = entry->GetSigOpCountWithAncestors();
|
|
|
|
}
|
|
|
|
|
2018-01-15 15:36:25 +01:00
|
|
|
int64_t GetModifiedFee() const { return iter->GetModifiedFee(); }
|
|
|
|
uint64_t GetSizeWithAncestors() const { return nSizeWithAncestors; }
|
|
|
|
CAmount GetModFeesWithAncestors() const { return nModFeesWithAncestors; }
|
|
|
|
size_t GetTxSize() const { return iter->GetTxSize(); }
|
|
|
|
const CTransaction& GetTx() const { return iter->GetTx(); }
|
|
|
|
|
2016-06-16 18:42:45 +02:00
|
|
|
CTxMemPool::txiter iter;
|
|
|
|
uint64_t nSizeWithAncestors;
|
|
|
|
CAmount nModFeesWithAncestors;
|
|
|
|
unsigned int nSigOpCountWithAncestors;
|
|
|
|
};
|
|
|
|
|
|
|
|
/** Comparator for CTxMemPool::txiter objects.
|
|
|
|
* It simply compares the internal memory address of the CTxMemPoolEntry object
|
|
|
|
* pointed to. This means it has no meaning, and is only useful for using them
|
|
|
|
* as key in other indexes.
|
|
|
|
*/
|
|
|
|
struct CompareCTxMemPoolIter {
|
|
|
|
bool operator()(const CTxMemPool::txiter& a, const CTxMemPool::txiter& b) const
|
|
|
|
{
|
|
|
|
return &(*a) < &(*b);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct modifiedentry_iter {
|
|
|
|
typedef CTxMemPool::txiter result_type;
|
|
|
|
result_type operator() (const CTxMemPoolModifiedEntry &entry) const
|
|
|
|
{
|
|
|
|
return entry.iter;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// A comparator that sorts transactions based on number of ancestors.
|
|
|
|
// This is sufficient to sort an ancestor package in an order that is valid
|
|
|
|
// to appear in a block.
|
|
|
|
struct CompareTxIterByAncestorCount {
|
2017-12-07 18:01:22 +01:00
|
|
|
bool operator()(const CTxMemPool::txiter &a, const CTxMemPool::txiter &b) const
|
2016-06-16 18:42:45 +02:00
|
|
|
{
|
|
|
|
if (a->GetCountWithAncestors() != b->GetCountWithAncestors())
|
|
|
|
return a->GetCountWithAncestors() < b->GetCountWithAncestors();
|
Merge #19478: Remove CTxMempool::mapLinks data structure member
296be8f58e02b39a58f017c52294aceed22c3ffd Get rid of unused functions CTxMemPool::GetMemPoolChildren, CTxMemPool::GetMemPoolParents (Jeremy Rubin)
46d955d196043cc297834baeebce31ff778dff80 Remove mapLinks in favor of entry inlined structs with iterator type erasure (Jeremy Rubin)
Pull request description:
Currently we have a peculiar data structure in the mempool called maplinks. Maplinks job is to track the in-pool children and parents of each transaction. This PR can be primarily understood and reviewed as a simple refactoring to remove this extra data structure, although it comes with a nice memory and performance improvement for free.
Maplinks is particularly peculiar because removing it is not as simple as just moving it's inner structure to the owning CTxMempoolEntry. Because TxLinks (the class storing the setEntries for parents and children) store txiters to each entry in the mempool corresponding to the parent or child, it means that the TxLinks type is "aware" of the boost multiindex (mapTx) it's coming from, which is in turn, aware of the entry type stored in mapTx. Thus we used maplinks to store this entry associated data we in an entirely separate data structure just to avoid a circular type reference caused by storing a txiter inside a CTxMempoolEntry.
It turns out, we can kill this circular reference by making use of iterator_to multiindex function and std::reference_wrapper. This allows us to get rid of the maplinks data structure and move the ownership of the parents/child sets to the entries themselves.
The benefit of this good all around, for any of the reasons given below the change would be acceptable, and it doesn't make the code harder to reason about or worse in any respect (as far as I can tell, there's no tradeoff).
### Simpler ownership model
No longer having to consistency check that mapLinks did have records for our CTxMempoolEntry, impossible to have a mapLinks entry outlive or incorrectly die before a CTxMempoolEntry.
### Memory Usage
We get rid of a O(Transactions) sized map in the mempool, which is a long lived data structure.
### Performance
If you have a CTxMemPoolEntry, you immediately know the address of it's children/parents, rather than having to do a O(log(Transactions)) lookup via maplinks (which we do very often). We do it in *so many* places that a true benchmark has to look at a full running node, but it is easy enough to show an improvement in this case.
The ComplexMemPool shows a good coherence check that we see the expected result of it being 12.5% faster / 1.14x faster.
```
Before:
# Benchmark, evals, iterations, total, min, max, median
ComplexMemPool, 5, 1, 1.40462, 0.277222, 0.285339, 0.279793
After:
# Benchmark, evals, iterations, total, min, max, median
ComplexMemPool, 5, 1, 1.22586, 0.243831, 0.247076, 0.244596
```
The ComplexMemPool benchmark only checks doing addUnchecked and TrimToSize for 800 transactions. While this bench does a good job of hammering the relevant types of function, it doesn't test everything.
Subbing in 5000 transactions shows a that the advantage isn't completely wiped out by other asymptotic factors (this isn't the only bottleneck in growing the mempool), but it's only a bit proportionally slower (10.8%, 1.12x), which adds evidence that this will be a good change for performance minded users.
```
# Benchmark, evals, iterations, total, min, max, median
ComplexMemPool, 5, 1, 59.1321, 11.5919, 12.235, 11.7068
# Benchmark, evals, iterations, total, min, max, median
ComplexMemPool, 5, 1, 52.1307, 10.2641, 10.5206, 10.4306
```
I don't think it's possible to come up with an example of where a maplinks based design would have better performance, but it's something for reviewers to consider.
# Discussion
## Why maplinks in the first place?
I spoke with the author of mapLinks (sdaftuar) a while back, and my recollection from our conversation was that it was implemented because he did not know how to resolve the circular dependency at the time, and there was no other reason for making it a separate map.
## Is iterator_to weird?
iterator_to is expressly for this purpose, see https://www.boost.org/doc/libs/1_51_0/libs/multi_index/doc/tutorial/indices.html#iterator_to
> iterator_to provides a way to retrieve an iterator to an element from a pointer to the element, thus making iterators and pointers interchangeable for the purposes of element pointing (not so for traversal) in many situations. This notwithstanding, it is not the aim of iterator_to to promote the usage of pointers as substitutes for real iterators: the latter are specifically designed for handling the elements of a container, and not only benefit from the iterator orientation of container interfaces, but are also capable of exposing many more programming bugs than raw pointers, both at compile and run time. iterator_to is thus meant to be used in scenarios where access via iterators is not suitable or desireable:
>
> - Interoperability with preexisting APIs based on pointers or references.
> - Publication of pointer-based interfaces (for instance, when designing a C-compatible library).
> - The exposure of pointers in place of iterators can act as a type erasure barrier effectively decoupling the user of the code from the implementation detail of which particular container is being used. Similar techniques, like the famous Pimpl idiom, are used in large projects to reduce dependencies and build times.
> - Self-referencing contexts where an element acts upon its owner container and no iterator to itself is available.
In other words, iterator_to is the perfect tool for the job by the last reason given. Under the hood it should just be a simple pointer cast and have no major runtime overhead (depending on if the function call is inlined).
Edit by laanwj: removed at sign from the description
ACKs for top commit:
jonatack:
re-ACK 296be8f per `git range-diff ab338a19 3ba1665 296be8f`, sanity check gcc 10.2 debug build is clean.
hebasto:
re-ACK 296be8f58e02b39a58f017c52294aceed22c3ffd, only rebased since my [previous](https://github.com/bitcoin/bitcoin/pull/19478#pullrequestreview-482400727) review (verified with `git range-diff`).
Tree-SHA512: f5c30a4936fcde6ae32a02823c303b3568a747c2681d11f87df88a149f984a6d3b4c81f391859afbeb68864ef7f6a3d8779f74a58e3de701b3d51f78e498682e
2020-09-07 12:06:38 +02:00
|
|
|
return CompareIteratorByHash()(a, b);
|
2016-06-16 18:42:45 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef boost::multi_index_container<
|
|
|
|
CTxMemPoolModifiedEntry,
|
|
|
|
boost::multi_index::indexed_by<
|
|
|
|
boost::multi_index::ordered_unique<
|
|
|
|
modifiedentry_iter,
|
|
|
|
CompareCTxMemPoolIter
|
|
|
|
>,
|
|
|
|
// sorted by modified ancestor fee rate
|
|
|
|
boost::multi_index::ordered_non_unique<
|
|
|
|
// Reuse same tag from CTxMemPool's similar index
|
|
|
|
boost::multi_index::tag<ancestor_score>,
|
|
|
|
boost::multi_index::identity<CTxMemPoolModifiedEntry>,
|
2018-01-15 15:36:25 +01:00
|
|
|
CompareTxMemPoolEntryByAncestorFee
|
2016-06-16 18:42:45 +02:00
|
|
|
>
|
|
|
|
>
|
|
|
|
> indexed_modified_transaction_set;
|
|
|
|
|
|
|
|
typedef indexed_modified_transaction_set::nth_index<0>::type::iterator modtxiter;
|
|
|
|
typedef indexed_modified_transaction_set::index<ancestor_score>::type::iterator modtxscoreiter;
|
|
|
|
|
|
|
|
struct update_for_parent_inclusion
|
|
|
|
{
|
2017-08-17 22:59:56 +02:00
|
|
|
explicit update_for_parent_inclusion(CTxMemPool::txiter it) : iter(it) {}
|
2016-06-16 18:42:45 +02:00
|
|
|
|
|
|
|
void operator() (CTxMemPoolModifiedEntry &e)
|
|
|
|
{
|
|
|
|
e.nModFeesWithAncestors -= iter->GetFee();
|
|
|
|
e.nSizeWithAncestors -= iter->GetTxSize();
|
|
|
|
e.nSigOpCountWithAncestors -= iter->GetSigOpCount();
|
|
|
|
}
|
|
|
|
|
|
|
|
CTxMemPool::txiter iter;
|
|
|
|
};
|
|
|
|
|
2013-07-31 15:43:35 +02:00
|
|
|
/** Generate a new block, without valid proof-of-work */
|
2016-06-13 11:27:11 +02:00
|
|
|
class BlockAssembler
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
// The constructed block template
|
|
|
|
std::unique_ptr<CBlockTemplate> pblocktemplate;
|
|
|
|
|
|
|
|
// Configuration parameters for the block size
|
2016-07-18 08:23:38 +02:00
|
|
|
unsigned int nBlockMaxSize;
|
2023-12-05 09:32:18 +01:00
|
|
|
unsigned int nBlockMaxSigOps;
|
2017-01-16 19:32:51 +01:00
|
|
|
CFeeRate blockMinFeeRate;
|
2016-06-13 11:27:11 +02:00
|
|
|
|
|
|
|
// Information on the current status of the block
|
|
|
|
uint64_t nBlockSize;
|
|
|
|
uint64_t nBlockTx;
|
|
|
|
unsigned int nBlockSigOps;
|
|
|
|
CAmount nFees;
|
|
|
|
CTxMemPool::setEntries inBlock;
|
|
|
|
|
|
|
|
// Chain context for the block
|
|
|
|
int nHeight;
|
|
|
|
int64_t nLockTimeCutoff;
|
|
|
|
const CChainParams& chainparams;
|
2019-07-03 15:46:43 +02:00
|
|
|
const CTxMemPool& m_mempool;
|
2023-06-01 09:32:41 +02:00
|
|
|
CChainState& m_chainstate;
|
2024-03-15 16:40:54 +01:00
|
|
|
CDeterministicMNManager& m_dmnman;
|
2024-02-28 17:50:48 +01:00
|
|
|
CCreditPoolManager& m_cpoolman;
|
2024-03-14 04:29:04 +01:00
|
|
|
CChainstateHelper& m_chain_helper;
|
2024-02-29 15:52:08 +01:00
|
|
|
CMNHFManager& m_mnhfman;
|
2022-09-22 13:14:48 +02:00
|
|
|
const llmq::CQuorumBlockProcessor& quorum_block_processor;
|
|
|
|
llmq::CChainLocksHandler& m_clhandler;
|
|
|
|
llmq::CInstantSendManager& m_isman;
|
refactor: remove the g_evoDb global; use NodeContext and locals (#5058)
<!--
*** Please remove the following help text before submitting: ***
Provide a general summary of your changes in the Title above
Pull requests without a rationale and clear improvement may be closed
immediately.
Please provide clear motivation for your patch and explain how it
improves
Dash Core user experience or Dash Core developer experience
significantly:
* Any test improvements or new tests that improve coverage are always
welcome.
* All other changes should have accompanying unit tests (see
`src/test/`) or
functional tests (see `test/`). Contributors should note which tests
cover
modified code. If no tests exist for a region of modified code, new
tests
should accompany the change.
* Bug fixes are most welcome when they come with steps to reproduce or
an
explanation of the potential issue as well as reasoning for the way the
bug
was fixed.
* Features are welcome, but might be rejected due to design or scope
issues.
If a feature is based on a lot of dependencies, contributors should
first
consider building the system outside of Dash Core, if possible.
-->
## Issue being fixed or feature implemented
<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here. -->
globals should be avoided to avoid annoying lifetime / nullptr /
initialization issues
## What was done?
<!--- Describe your changes in detail -->
removed a global, g_evoDB
## How Has This Been Tested?
<!--- Please describe in detail how you tested your changes. -->
<!--- Include details of your testing environment, and the tests you ran
to -->
<!--- see how your change affects other areas of the code, etc. -->
make check
## Breaking Changes
<!--- Please describe any breaking changes your code introduces -->
none
## Checklist:
<!--- Go over all the following points, and put an `x` in all the boxes
that apply. -->
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [ ] I have added or updated relevant unit/integration/functional/e2e
tests
- [ ] I have made corresponding changes to the documentation
**For repository code-owners and collaborators only**
- [ ] I have assigned this pull request to a milestone
Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
Co-authored-by: Kittywhiskers Van Gogh <63189531+kittywhiskers@users.noreply.github.com>
2022-12-10 18:58:17 +01:00
|
|
|
CEvoDB& m_evoDb;
|
2016-06-13 11:27:11 +02:00
|
|
|
|
|
|
|
public:
|
2017-03-01 12:37:42 +01:00
|
|
|
struct Options {
|
|
|
|
Options();
|
|
|
|
size_t nBlockMaxSize;
|
|
|
|
CFeeRate blockMinFeeRate;
|
|
|
|
};
|
|
|
|
|
2024-03-02 22:26:00 +01:00
|
|
|
explicit BlockAssembler(CChainState& chainstate, const NodeContext& node, const CTxMemPool& mempool, const CChainParams& params);
|
|
|
|
explicit BlockAssembler(CChainState& chainstate, const NodeContext& node, const CTxMemPool& mempool, const CChainParams& params,
|
|
|
|
const Options& options);
|
2017-03-01 12:37:42 +01:00
|
|
|
|
2016-06-13 11:27:11 +02:00
|
|
|
/** Construct a new block template with coinbase to scriptPubKeyIn */
|
2023-06-01 09:32:41 +02:00
|
|
|
std::unique_ptr<CBlockTemplate> CreateNewBlock(const CScript& scriptPubKeyIn);
|
2016-06-13 11:27:11 +02:00
|
|
|
|
2022-10-15 22:11:49 +02:00
|
|
|
inline static std::optional<int64_t> m_last_block_num_txs{};
|
|
|
|
inline static std::optional<int64_t> m_last_block_size{};
|
2019-02-15 14:56:43 +01:00
|
|
|
|
2016-06-13 11:27:11 +02:00
|
|
|
private:
|
|
|
|
// utility functions
|
|
|
|
/** Clear the block's state and prepare for assembling a new block */
|
|
|
|
void resetBlock();
|
|
|
|
/** Add a tx to the block */
|
|
|
|
void AddToBlock(CTxMemPool::txiter iter);
|
|
|
|
|
|
|
|
// Methods for how to add transactions to a block.
|
2017-03-30 20:53:31 +02:00
|
|
|
/** Add transactions based on feerate including unconfirmed ancestors
|
|
|
|
* Increments nPackagesSelected / nDescendantsUpdated with corresponding
|
|
|
|
* statistics from the package selection (for logging statistics). */
|
2023-09-21 09:20:42 +02:00
|
|
|
void addPackageTxs(int& nPackagesSelected, int& nDescendantsUpdated,
|
2023-10-30 15:57:20 +01:00
|
|
|
const CBlockIndex* pindexPrev) EXCLUSIVE_LOCKS_REQUIRED(m_mempool.cs);
|
2016-06-13 11:27:11 +02:00
|
|
|
|
2016-06-16 18:42:45 +02:00
|
|
|
// helper functions for addPackageTxs()
|
|
|
|
/** Remove confirmed (inBlock) entries from given set */
|
|
|
|
void onlyUnconfirmed(CTxMemPool::setEntries& testSet);
|
|
|
|
/** Test if a new package would "fit" in the block */
|
2017-08-16 02:09:10 +02:00
|
|
|
bool TestPackage(uint64_t packageSize, unsigned int packageSigOps) const;
|
2016-07-18 08:23:38 +02:00
|
|
|
/** Perform checks on each transaction in a package:
|
2017-09-18 13:22:21 +02:00
|
|
|
* locktime
|
2016-07-18 08:23:38 +02:00
|
|
|
* These checks should always succeed, and they're here
|
|
|
|
* only as an extra check in case of suboptimal node configuration */
|
2021-01-07 09:03:35 +01:00
|
|
|
bool TestPackageTransactions(const CTxMemPool::setEntries& package) const;
|
2016-06-16 18:42:45 +02:00
|
|
|
/** Return true if given transaction from mapTx has already been evaluated,
|
|
|
|
* or if the transaction's cached data in mapTx is incorrect. */
|
2019-07-03 15:46:43 +02:00
|
|
|
bool SkipMapTxEntry(CTxMemPool::txiter it, indexed_modified_transaction_set& mapModifiedTx, CTxMemPool::setEntries& failedTx) EXCLUSIVE_LOCKS_REQUIRED(m_mempool.cs);
|
2016-06-16 18:42:45 +02:00
|
|
|
/** Sort the package in an order that is valid to appear in a block */
|
2018-03-16 00:12:47 +01:00
|
|
|
void SortForBlock(const CTxMemPool::setEntries& package, std::vector<CTxMemPool::txiter>& sortedEntries);
|
2016-06-16 18:42:45 +02:00
|
|
|
/** Add descendants of given transactions to mapModifiedTx with ancestor
|
2017-03-30 20:53:31 +02:00
|
|
|
* state updated assuming given transactions are inBlock. Returns number
|
|
|
|
* of updated descendants. */
|
2019-07-03 15:46:43 +02:00
|
|
|
int UpdatePackagesForAdded(const CTxMemPool::setEntries& alreadyAdded, indexed_modified_transaction_set& mapModifiedTx) EXCLUSIVE_LOCKS_REQUIRED(m_mempool.cs);
|
2016-06-13 11:27:11 +02:00
|
|
|
};
|
|
|
|
|
2013-07-31 15:43:35 +02:00
|
|
|
/** Modify the extranonce in a block */
|
2015-08-08 18:18:41 +02:00
|
|
|
void IncrementExtraNonce(CBlock* pblock, const CBlockIndex* pindexPrev, unsigned int& nExtraNonce);
|
2015-05-22 23:49:50 +02:00
|
|
|
int64_t UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, const CBlockIndex* pindexPrev);
|
2013-07-31 15:43:35 +02:00
|
|
|
|
|
|
|
#endif // BITCOIN_MINER_H
|