mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-05-30 05:52:33 +02:00
net: save high-bandwidth mode states in CNodeStats
This commit is contained in:
parent
655937ebcb
commit
30bc8fab68
@ -563,6 +563,8 @@ void CNode::copyStats(CNodeStats &stats, const std::vector<bool> &m_asmap)
|
|||||||
}
|
}
|
||||||
stats.fInbound = IsInboundConn();
|
stats.fInbound = IsInboundConn();
|
||||||
stats.m_manual_connection = IsManualConn();
|
stats.m_manual_connection = IsManualConn();
|
||||||
|
X(m_bip152_highbandwidth_to);
|
||||||
|
X(m_bip152_highbandwidth_from);
|
||||||
X(nStartingHeight);
|
X(nStartingHeight);
|
||||||
{
|
{
|
||||||
LOCK(cs_vSend);
|
LOCK(cs_vSend);
|
||||||
|
@ -681,6 +681,8 @@ public:
|
|||||||
std::string cleanSubVer;
|
std::string cleanSubVer;
|
||||||
bool fInbound;
|
bool fInbound;
|
||||||
bool m_manual_connection;
|
bool m_manual_connection;
|
||||||
|
bool m_bip152_highbandwidth_to;
|
||||||
|
bool m_bip152_highbandwidth_from;
|
||||||
int nStartingHeight;
|
int nStartingHeight;
|
||||||
uint64_t nSendBytes;
|
uint64_t nSendBytes;
|
||||||
mapMsgCmdSize mapSendBytesPerMsgCmd;
|
mapMsgCmdSize mapSendBytesPerMsgCmd;
|
||||||
@ -942,6 +944,10 @@ protected:
|
|||||||
public:
|
public:
|
||||||
uint256 hashContinue;
|
uint256 hashContinue;
|
||||||
std::atomic<int> nStartingHeight{-1};
|
std::atomic<int> nStartingHeight{-1};
|
||||||
|
// We selected peer as (compact blocks) high-bandwidth peer (BIP152)
|
||||||
|
std::atomic<bool> m_bip152_highbandwidth_to{false};
|
||||||
|
// Peer selected us as (compact blocks) high-bandwidth peer (BIP152)
|
||||||
|
std::atomic<bool> m_bip152_highbandwidth_from{false};
|
||||||
|
|
||||||
// flood relay
|
// flood relay
|
||||||
std::vector<CAddress> vAddrToSend;
|
std::vector<CAddress> vAddrToSend;
|
||||||
|
@ -670,11 +670,15 @@ static void MaybeSetPeerAsAnnouncingHeaderAndIDs(NodeId nodeid, CConnman& connma
|
|||||||
// blocks using compact encodings.
|
// blocks using compact encodings.
|
||||||
connman.ForNode(lNodesAnnouncingHeaderAndIDs.front(), [&connman, nCMPCTBLOCKVersion](CNode* pnodeStop){
|
connman.ForNode(lNodesAnnouncingHeaderAndIDs.front(), [&connman, nCMPCTBLOCKVersion](CNode* pnodeStop){
|
||||||
connman.PushMessage(pnodeStop, CNetMsgMaker(pnodeStop->GetCommonVersion()).Make(NetMsgType::SENDCMPCT, /*fAnnounceUsingCMPCTBLOCK=*/false, nCMPCTBLOCKVersion));
|
connman.PushMessage(pnodeStop, CNetMsgMaker(pnodeStop->GetCommonVersion()).Make(NetMsgType::SENDCMPCT, /*fAnnounceUsingCMPCTBLOCK=*/false, nCMPCTBLOCKVersion));
|
||||||
|
// save BIP152 bandwidth state: we select peer to be low-bandwidth
|
||||||
|
pnodeStop->m_bip152_highbandwidth_to = false;
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
lNodesAnnouncingHeaderAndIDs.pop_front();
|
lNodesAnnouncingHeaderAndIDs.pop_front();
|
||||||
}
|
}
|
||||||
connman.PushMessage(pfrom, CNetMsgMaker(pfrom->GetCommonVersion()).Make(NetMsgType::SENDCMPCT, /*fAnnounceUsingCMPCTBLOCK=*/true, nCMPCTBLOCKVersion));
|
connman.PushMessage(pfrom, CNetMsgMaker(pfrom->GetCommonVersion()).Make(NetMsgType::SENDCMPCT, /*fAnnounceUsingCMPCTBLOCK=*/true, nCMPCTBLOCKVersion));
|
||||||
|
// save BIP152 bandwidth state: we select peer to be high-bandwidth
|
||||||
|
pfrom->m_bip152_highbandwidth_to = true;
|
||||||
lNodesAnnouncingHeaderAndIDs.push_back(pfrom->GetId());
|
lNodesAnnouncingHeaderAndIDs.push_back(pfrom->GetId());
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
@ -2652,8 +2656,12 @@ void PeerManager::ProcessMessage(CNode& pfrom, const std::string& msg_type, CDat
|
|||||||
State(pfrom.GetId())->fProvidesHeaderAndIDs = true;
|
State(pfrom.GetId())->fProvidesHeaderAndIDs = true;
|
||||||
State(pfrom.GetId())->fWantsCmpctWitness = nCMPCTBLOCKVersion == 2;
|
State(pfrom.GetId())->fWantsCmpctWitness = nCMPCTBLOCKVersion == 2;
|
||||||
}
|
}
|
||||||
if (State(pfrom.GetId())->fWantsCmpctWitness == (nCMPCTBLOCKVersion == 2)) // ignore later version announces
|
if (State(pfrom.GetId())->fWantsCmpctWitness == (nCMPCTBLOCKVersion == 2)) { // ignore later version announces
|
||||||
State(pfrom.GetId())->fPreferHeaderAndIDs = fAnnounceUsingCMPCTBLOCK;
|
State(pfrom.GetId())->fPreferHeaderAndIDs = fAnnounceUsingCMPCTBLOCK;
|
||||||
|
// save whether peer selects us as BIP152 high-bandwidth peer
|
||||||
|
// (receiving sendcmpct(1) signals high-bandwidth, sendcmpct(0) low-bandwidth)
|
||||||
|
pfrom.m_bip152_highbandwidth_from = fAnnounceUsingCMPCTBLOCK;
|
||||||
|
}
|
||||||
if (!State(pfrom.GetId())->fSupportsDesiredCmpctVersion) {
|
if (!State(pfrom.GetId())->fSupportsDesiredCmpctVersion) {
|
||||||
if (pfrom.GetLocalServices() & NODE_WITNESS)
|
if (pfrom.GetLocalServices() & NODE_WITNESS)
|
||||||
State(pfrom.GetId())->fSupportsDesiredCmpctVersion = (nCMPCTBLOCKVersion == 2);
|
State(pfrom.GetId())->fSupportsDesiredCmpctVersion = (nCMPCTBLOCKVersion == 2);
|
||||||
|
Loading…
Reference in New Issue
Block a user