mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-22 14:52:41 +02:00
net_processing: move MaybeSetPeerAsAnnouncingHeadersAndIDs into PeerManagerImpl
Allows making lNodesAnnouncingHeaderAndIDs and nPeersWithValidatedDownloads member vars instead of globals.
This commit is contained in:
parent
7b7117efd0
commit
39c2a69bc2
@ -452,20 +452,28 @@ private:
|
|||||||
/** Expiration-time ordered list of (expire time, relay map entry) pairs. */
|
/** Expiration-time ordered list of (expire time, relay map entry) pairs. */
|
||||||
std::deque<std::pair<int64_t, MapRelay::iterator>> vRelayExpiration GUARDED_BY(cs_main);
|
std::deque<std::pair<int64_t, MapRelay::iterator>> vRelayExpiration GUARDED_BY(cs_main);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When a peer sends us a valid block, instruct it to announce blocks to us
|
||||||
|
* using CMPCTBLOCK if possible by adding its nodeid to the end of
|
||||||
|
* lNodesAnnouncingHeaderAndIDs, and keeping that list under a certain size by
|
||||||
|
* removing the first element if necessary.
|
||||||
|
*/
|
||||||
|
void MaybeSetPeerAsAnnouncingHeaderAndIDs(NodeId nodeid, CConnman& connman) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
||||||
|
|
||||||
|
/** Stack of nodes which we have set to announce using compact blocks */
|
||||||
|
std::list<NodeId> lNodesAnnouncingHeaderAndIDs GUARDED_BY(cs_main);
|
||||||
|
|
||||||
|
/** Number of peers from which we're downloading blocks. */
|
||||||
|
int nPeersWithValidatedDownloads GUARDED_BY(cs_main) = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
/** Stack of nodes which we have set to announce using compact blocks */
|
|
||||||
std::list<NodeId> lNodesAnnouncingHeaderAndIDs GUARDED_BY(cs_main);
|
|
||||||
|
|
||||||
/** Number of preferable block download peers. */
|
/** Number of preferable block download peers. */
|
||||||
int nPreferredDownload GUARDED_BY(cs_main) = 0;
|
int nPreferredDownload GUARDED_BY(cs_main) = 0;
|
||||||
|
|
||||||
/** Number of peers from which we're downloading blocks. */
|
|
||||||
int nPeersWithValidatedDownloads GUARDED_BY(cs_main) = 0;
|
|
||||||
|
|
||||||
struct IteratorComparator
|
struct IteratorComparator
|
||||||
{
|
{
|
||||||
template<typename I>
|
template<typename I>
|
||||||
@ -731,13 +739,7 @@ static void UpdateBlockAvailability(NodeId nodeid, const uint256 &hash) EXCLUSIV
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
void PeerManagerImpl::MaybeSetPeerAsAnnouncingHeaderAndIDs(NodeId nodeid, CConnman& connman) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
|
||||||
* When a peer sends us a valid block, instruct it to announce blocks to us
|
|
||||||
* using CMPCTBLOCK if possible by adding its nodeid to the end of
|
|
||||||
* lNodesAnnouncingHeaderAndIDs, and keeping that list under a certain size by
|
|
||||||
* removing the first element if necessary.
|
|
||||||
*/
|
|
||||||
static void MaybeSetPeerAsAnnouncingHeaderAndIDs(NodeId nodeid, CConnman& connman) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
|
|
||||||
{
|
{
|
||||||
AssertLockHeld(cs_main);
|
AssertLockHeld(cs_main);
|
||||||
CNodeState* nodestate = State(nodeid);
|
CNodeState* nodestate = State(nodeid);
|
||||||
@ -753,7 +755,7 @@ static void MaybeSetPeerAsAnnouncingHeaderAndIDs(NodeId nodeid, CConnman& connma
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
connman.ForNode(nodeid, [&connman](CNode* pfrom) EXCLUSIVE_LOCKS_REQUIRED(::cs_main) {
|
connman.ForNode(nodeid, [this, &connman](CNode* pfrom) EXCLUSIVE_LOCKS_REQUIRED(::cs_main) {
|
||||||
AssertLockHeld(::cs_main);
|
AssertLockHeld(::cs_main);
|
||||||
uint64_t nCMPCTBLOCKVersion = (pfrom->GetLocalServices() & NODE_WITNESS) ? 2 : 1;
|
uint64_t nCMPCTBLOCKVersion = (pfrom->GetLocalServices() & NODE_WITNESS) ? 2 : 1;
|
||||||
if (lNodesAnnouncingHeaderAndIDs.size() >= 3) {
|
if (lNodesAnnouncingHeaderAndIDs.size() >= 3) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user