Skip to content

Commit

Permalink
net_processing: move AddToCompactExtraTransactions into PeerManagerImpl
Browse files Browse the repository at this point in the history
Summary:
Allows making vExtraTxnForCompact and vExtraTxnForCompactIt member vars
instead of globals.

This is a backport of [[bitcoin/bitcoin#21148 | core#21148]] [13/14]
bitcoin/bitcoin@eeeafb3

Depends on D11491

Test Plan:
With clang and debug:
`ninja all check-all`

Reviewers: #bitcoin_abc, sdulfari

Reviewed By: #bitcoin_abc, sdulfari

Differential Revision: https://reviews.bitcoinabc.org/D11492
  • Loading branch information
ajtowns authored and PiRK committed May 19, 2022
1 parent 66572c1 commit 8b798a6
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions src/net_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,21 @@ class PeerManagerImpl final : public PeerManager {
/** Storage for orphan information */
TxOrphanage m_orphanage;

void AddToCompactExtraTransactions(const CTransactionRef &tx)
EXCLUSIVE_LOCKS_REQUIRED(g_cs_orphans);

/**
* Orphan/conflicted/etc transactions that are kept for compact block
* reconstruction.
* The last
* -blockreconstructionextratxn/DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN of
* these are kept in a ring buffer
*/
std::vector<std::pair<TxHash, CTransactionRef>>
vExtraTxnForCompact GUARDED_BY(g_cs_orphans);
/** Offset into vExtraTxnForCompact to insert the next tx */
size_t vExtraTxnForCompactIt GUARDED_BY(g_cs_orphans) = 0;

/**
* Checks if address relay is permitted with peer. If needed, initializes
* the m_addr_known bloom filter and sets m_addr_relay_enabled to true.
Expand Down Expand Up @@ -839,17 +854,6 @@ std::unique_ptr<CRollingBloomFilter>

/** Number of preferable block download peers. */
int nPreferredDownload GUARDED_BY(cs_main) = 0;

/**
* Orphan/conflicted/etc transactions that are kept for compact block
* reconstruction.
* The last -blockreconstructionextratxn/DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN
* of these are kept in a ring buffer
*/
static std::vector<std::pair<TxHash, CTransactionRef>>
vExtraTxnForCompact GUARDED_BY(g_cs_orphans);
/** Offset into vExtraTxnForCompact to insert the next tx */
static size_t vExtraTxnForCompactIt GUARDED_BY(g_cs_orphans) = 0;
} // namespace

namespace {
Expand Down Expand Up @@ -1734,8 +1738,7 @@ bool PeerManagerImpl::GetNodeStateStats(NodeId nodeid, CNodeStateStats &stats) {
return true;
}

static void AddToCompactExtraTransactions(const CTransactionRef &tx)
EXCLUSIVE_LOCKS_REQUIRED(g_cs_orphans) {
void PeerManagerImpl::AddToCompactExtraTransactions(const CTransactionRef &tx) {
size_t max_extra_txn = gArgs.GetArg("-blockreconstructionextratxn",
DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN);
if (max_extra_txn <= 0) {
Expand Down

0 comments on commit 8b798a6

Please sign in to comment.