Skip to content

Commit 10b83e2

Browse files
committed
[net processing] Move block cache state into PeerManagerImpl
1 parent a4c55a9 commit 10b83e2

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/net_processing.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,14 @@ class PeerManagerImpl final : public PeerManager
679679
std::chrono::microseconds NextInvToInbounds(std::chrono::microseconds now,
680680
std::chrono::seconds average_interval);
681681

682+
683+
// All of the following cache a recent block, and are protected by cs_most_recent_block
684+
RecursiveMutex cs_most_recent_block;
685+
std::shared_ptr<const CBlock> most_recent_block GUARDED_BY(cs_most_recent_block);
686+
std::shared_ptr<const CBlockHeaderAndShortTxIDs> most_recent_compact_block GUARDED_BY(cs_most_recent_block);
687+
uint256 most_recent_block_hash GUARDED_BY(cs_most_recent_block);
688+
bool fWitnessesPresentInMostRecentCompactBlock GUARDED_BY(cs_most_recent_block){false};
689+
682690
/** Have we requested this block from a peer */
683691
bool IsBlockRequested(const uint256& hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
684692

@@ -1613,13 +1621,6 @@ void PeerManagerImpl::BlockDisconnected(const std::shared_ptr<const CBlock> &blo
16131621
m_recent_confirmed_transactions.reset();
16141622
}
16151623

1616-
// All of the following cache a recent block, and are protected by cs_most_recent_block
1617-
static RecursiveMutex cs_most_recent_block;
1618-
static std::shared_ptr<const CBlock> most_recent_block GUARDED_BY(cs_most_recent_block);
1619-
static std::shared_ptr<const CBlockHeaderAndShortTxIDs> most_recent_compact_block GUARDED_BY(cs_most_recent_block);
1620-
static uint256 most_recent_block_hash GUARDED_BY(cs_most_recent_block);
1621-
static bool fWitnessesPresentInMostRecentCompactBlock GUARDED_BY(cs_most_recent_block);
1622-
16231624
/**
16241625
* Maintain state about the best-seen block and fast-announce a compact block
16251626
* to compatible peers.

0 commit comments

Comments
 (0)