@@ -670,11 +670,15 @@ static void MaybeSetPeerAsAnnouncingHeaderAndIDs(NodeId nodeid, CConnman& connma
670
670
// blocks using compact encodings.
671
671
connman.ForNode (lNodesAnnouncingHeaderAndIDs.front (), [&connman, nCMPCTBLOCKVersion](CNode* pnodeStop){
672
672
connman.PushMessage (pnodeStop, CNetMsgMaker (pnodeStop->GetCommonVersion ()).Make (NetMsgType::SENDCMPCT, /* fAnnounceUsingCMPCTBLOCK=*/ false , nCMPCTBLOCKVersion));
673
+ // save BIP152 bandwidth state: we select peer to be low-bandwidth
674
+ pnodeStop->m_bip152_highbandwidth_to = false ;
673
675
return true ;
674
676
});
675
677
lNodesAnnouncingHeaderAndIDs.pop_front ();
676
678
}
677
679
connman.PushMessage (pfrom, CNetMsgMaker (pfrom->GetCommonVersion ()).Make (NetMsgType::SENDCMPCT, /* fAnnounceUsingCMPCTBLOCK=*/ true , nCMPCTBLOCKVersion));
680
+ // save BIP152 bandwidth state: we select peer to be high-bandwidth
681
+ pfrom->m_bip152_highbandwidth_to = true ;
678
682
lNodesAnnouncingHeaderAndIDs.push_back (pfrom->GetId ());
679
683
return true ;
680
684
});
@@ -2652,8 +2656,12 @@ void PeerManager::ProcessMessage(CNode& pfrom, const std::string& msg_type, CDat
2652
2656
State (pfrom.GetId ())->fProvidesHeaderAndIDs = true ;
2653
2657
State (pfrom.GetId ())->fWantsCmpctWitness = nCMPCTBLOCKVersion == 2 ;
2654
2658
}
2655
- if (State (pfrom.GetId ())->fWantsCmpctWitness == (nCMPCTBLOCKVersion == 2 )) // ignore later version announces
2659
+ if (State (pfrom.GetId ())->fWantsCmpctWitness == (nCMPCTBLOCKVersion == 2 )) { // ignore later version announces
2656
2660
State (pfrom.GetId ())->fPreferHeaderAndIDs = fAnnounceUsingCMPCTBLOCK ;
2661
+ // save whether peer selects us as BIP152 high-bandwidth peer
2662
+ // (receiving sendcmpct(1) signals high-bandwidth, sendcmpct(0) low-bandwidth)
2663
+ pfrom.m_bip152_highbandwidth_from = fAnnounceUsingCMPCTBLOCK ;
2664
+ }
2657
2665
if (!State (pfrom.GetId ())->fSupportsDesiredCmpctVersion ) {
2658
2666
if (pfrom.GetLocalServices () & NODE_WITNESS)
2659
2667
State (pfrom.GetId ())->fSupportsDesiredCmpctVersion = (nCMPCTBLOCKVersion == 2 );
0 commit comments