@@ -968,49 +968,48 @@ void PeerManagerImpl::MaybeSetPeerAsAnnouncingHeaderAndIDs(NodeId nodeid)
968
968
// Don't request compact blocks if the peer has not signalled support
969
969
return ;
970
970
}
971
- if (nodestate->m_provides_cmpctblocks ) {
972
- int num_outbound_hb_peers = 0 ;
973
- for (std::list<NodeId>::iterator it = lNodesAnnouncingHeaderAndIDs.begin (); it != lNodesAnnouncingHeaderAndIDs.end (); it++) {
974
- if (*it == nodeid) {
975
- lNodesAnnouncingHeaderAndIDs.erase (it);
976
- lNodesAnnouncingHeaderAndIDs.push_back (nodeid);
977
- return ;
978
- }
979
- CNodeState *state = State (*it);
980
- if (state != nullptr && !state->m_is_inbound ) ++num_outbound_hb_peers;
981
- }
982
- if (nodestate->m_is_inbound ) {
983
- // If we're adding an inbound HB peer, make sure we're not removing
984
- // our last outbound HB peer in the process.
985
- if (lNodesAnnouncingHeaderAndIDs.size () >= 3 && num_outbound_hb_peers == 1 ) {
986
- CNodeState *remove_node = State (lNodesAnnouncingHeaderAndIDs.front ());
987
- if (remove_node != nullptr && !remove_node->m_is_inbound ) {
988
- // Put the HB outbound peer in the second slot, so that it
989
- // doesn't get removed.
990
- std::swap (lNodesAnnouncingHeaderAndIDs.front (), *std::next (lNodesAnnouncingHeaderAndIDs.begin ()));
991
- }
992
- }
971
+
972
+ int num_outbound_hb_peers = 0 ;
973
+ for (std::list<NodeId>::iterator it = lNodesAnnouncingHeaderAndIDs.begin (); it != lNodesAnnouncingHeaderAndIDs.end (); it++) {
974
+ if (*it == nodeid) {
975
+ lNodesAnnouncingHeaderAndIDs.erase (it);
976
+ lNodesAnnouncingHeaderAndIDs.push_back (nodeid);
977
+ return ;
993
978
}
994
- m_connman. ForNode (nodeid, [ this ](CNode* pfrom) EXCLUSIVE_LOCKS_REQUIRED (::cs_main) {
995
- AssertLockHeld (::cs_main) ;
996
- if (lNodesAnnouncingHeaderAndIDs. size () >= 3 ) {
997
- // As per BIP152, we only get 3 of our peers to announce
998
- // blocks using compact encodings.
999
- m_connman. ForNode (lNodesAnnouncingHeaderAndIDs. front (), [ this ](CNode* pnodeStop){
1000
- m_connman. PushMessage (pnodeStop, CNetMsgMaker (pnodeStop-> GetCommonVersion ()). Make (NetMsgType::SENDCMPCT, /* high_bandwidth= */ false , /* version= */ CMPCTBLOCKS_VERSION));
1001
- // save BIP152 bandwidth state: we select peer to be low-bandwidth
1002
- pnodeStop-> m_bip152_highbandwidth_to = false ;
1003
- return true ;
1004
- });
1005
- lNodesAnnouncingHeaderAndIDs.pop_front ( );
979
+ CNodeState *state = State (*it);
980
+ if (state != nullptr && !state-> m_is_inbound ) ++num_outbound_hb_peers ;
981
+ }
982
+ if (nodestate-> m_is_inbound ) {
983
+ // If we're adding an inbound HB peer, make sure we're not removing
984
+ // our last outbound HB peer in the process.
985
+ if (lNodesAnnouncingHeaderAndIDs. size () >= 3 && num_outbound_hb_peers == 1 ) {
986
+ CNodeState *remove_node = State (lNodesAnnouncingHeaderAndIDs. front ());
987
+ if (remove_node != nullptr && !remove_node-> m_is_inbound ) {
988
+ // Put the HB outbound peer in the second slot, so that it
989
+ // doesn't get removed.
990
+ std::swap ( lNodesAnnouncingHeaderAndIDs.front (), * std::next (lNodesAnnouncingHeaderAndIDs. begin ()) );
1006
991
}
1007
- m_connman.PushMessage (pfrom, CNetMsgMaker (pfrom->GetCommonVersion ()).Make (NetMsgType::SENDCMPCT, /* high_bandwidth=*/ true , /* version=*/ CMPCTBLOCKS_VERSION));
1008
- // save BIP152 bandwidth state: we select peer to be high-bandwidth
1009
- pfrom->m_bip152_highbandwidth_to = true ;
1010
- lNodesAnnouncingHeaderAndIDs.push_back (pfrom->GetId ());
1011
- return true ;
1012
- });
992
+ }
1013
993
}
994
+ m_connman.ForNode (nodeid, [this ](CNode* pfrom) EXCLUSIVE_LOCKS_REQUIRED (::cs_main) {
995
+ AssertLockHeld (::cs_main);
996
+ if (lNodesAnnouncingHeaderAndIDs.size () >= 3 ) {
997
+ // As per BIP152, we only get 3 of our peers to announce
998
+ // blocks using compact encodings.
999
+ m_connman.ForNode (lNodesAnnouncingHeaderAndIDs.front (), [this ](CNode* pnodeStop){
1000
+ m_connman.PushMessage (pnodeStop, CNetMsgMaker (pnodeStop->GetCommonVersion ()).Make (NetMsgType::SENDCMPCT, /* high_bandwidth=*/ false , /* version=*/ CMPCTBLOCKS_VERSION));
1001
+ // save BIP152 bandwidth state: we select peer to be low-bandwidth
1002
+ pnodeStop->m_bip152_highbandwidth_to = false ;
1003
+ return true ;
1004
+ });
1005
+ lNodesAnnouncingHeaderAndIDs.pop_front ();
1006
+ }
1007
+ m_connman.PushMessage (pfrom, CNetMsgMaker (pfrom->GetCommonVersion ()).Make (NetMsgType::SENDCMPCT, /* high_bandwidth=*/ true , /* version=*/ CMPCTBLOCKS_VERSION));
1008
+ // save BIP152 bandwidth state: we select peer to be high-bandwidth
1009
+ pfrom->m_bip152_highbandwidth_to = true ;
1010
+ lNodesAnnouncingHeaderAndIDs.push_back (pfrom->GetId ());
1011
+ return true ;
1012
+ });
1014
1013
}
1015
1014
1016
1015
bool PeerManagerImpl::TipMayBeStale ()
0 commit comments