@@ -175,6 +175,8 @@ static constexpr double MAX_ADDR_RATE_PER_SECOND{0.1};
175
175
* based increments won't go above this, but the MAX_ADDR_TO_SEND increment following GETADDR
176
176
* is exempt from this limit). */
177
177
static constexpr size_t MAX_ADDR_PROCESSING_TOKEN_BUCKET{MAX_ADDR_TO_SEND};
178
+ /* * The compactblocks version we support. See BIP 152. */
179
+ static constexpr uint64_t CMPCTBLOCKS_VERSION{2 };
178
180
179
181
// Internal stuff
180
182
namespace {
@@ -1003,19 +1005,18 @@ void PeerManagerImpl::MaybeSetPeerAsAnnouncingHeaderAndIDs(NodeId nodeid)
1003
1005
}
1004
1006
m_connman.ForNode (nodeid, [this ](CNode* pfrom) EXCLUSIVE_LOCKS_REQUIRED (::cs_main) {
1005
1007
AssertLockHeld (::cs_main);
1006
- uint64_t nCMPCTBLOCKVersion = 2 ;
1007
1008
if (lNodesAnnouncingHeaderAndIDs.size () >= 3 ) {
1008
1009
// As per BIP152, we only get 3 of our peers to announce
1009
1010
// blocks using compact encodings.
1010
- m_connman.ForNode (lNodesAnnouncingHeaderAndIDs.front (), [this , nCMPCTBLOCKVersion ](CNode* pnodeStop){
1011
- m_connman.PushMessage (pnodeStop, CNetMsgMaker (pnodeStop->GetCommonVersion ()).Make (NetMsgType::SENDCMPCT, /* fAnnounceUsingCMPCTBLOCK =*/ false , nCMPCTBLOCKVersion ));
1011
+ m_connman.ForNode (lNodesAnnouncingHeaderAndIDs.front (), [this ](CNode* pnodeStop){
1012
+ m_connman.PushMessage (pnodeStop, CNetMsgMaker (pnodeStop->GetCommonVersion ()).Make (NetMsgType::SENDCMPCT, /* high_bandwidth =*/ false , /* version= */ CMPCTBLOCKS_VERSION ));
1012
1013
// save BIP152 bandwidth state: we select peer to be low-bandwidth
1013
1014
pnodeStop->m_bip152_highbandwidth_to = false ;
1014
1015
return true ;
1015
1016
});
1016
1017
lNodesAnnouncingHeaderAndIDs.pop_front ();
1017
1018
}
1018
- m_connman.PushMessage (pfrom, CNetMsgMaker (pfrom->GetCommonVersion ()).Make (NetMsgType::SENDCMPCT, /* fAnnounceUsingCMPCTBLOCK =*/ true , nCMPCTBLOCKVersion ));
1019
+ m_connman.PushMessage (pfrom, CNetMsgMaker (pfrom->GetCommonVersion ()).Make (NetMsgType::SENDCMPCT, /* high_bandwidth =*/ true , /* version= */ CMPCTBLOCKS_VERSION ));
1019
1020
// save BIP152 bandwidth state: we select peer to be high-bandwidth
1020
1021
pfrom->m_bip152_highbandwidth_to = true ;
1021
1022
lNodesAnnouncingHeaderAndIDs.push_back (pfrom->GetId ());
@@ -2861,16 +2862,12 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
2861
2862
m_connman.PushMessage (&pfrom, msgMaker.Make (NetMsgType::SENDHEADERS));
2862
2863
}
2863
2864
if (pfrom.GetCommonVersion () >= SHORT_IDS_BLOCKS_VERSION) {
2864
- // Tell our peer we are willing to provide version 1 or 2 cmpctblocks
2865
+ // Tell our peer we are willing to provide version 2 cmpctblocks.
2865
2866
// However, we do not request new block announcements using
2866
2867
// cmpctblock messages.
2867
2868
// We send this to non-NODE NETWORK peers as well, because
2868
2869
// they may wish to request compact blocks from us
2869
- bool fAnnounceUsingCMPCTBLOCK = false ;
2870
- uint64_t nCMPCTBLOCKVersion = 2 ;
2871
- m_connman.PushMessage (&pfrom, msgMaker.Make (NetMsgType::SENDCMPCT, fAnnounceUsingCMPCTBLOCK , nCMPCTBLOCKVersion));
2872
- nCMPCTBLOCKVersion = 1 ;
2873
- m_connman.PushMessage (&pfrom, msgMaker.Make (NetMsgType::SENDCMPCT, fAnnounceUsingCMPCTBLOCK , nCMPCTBLOCKVersion));
2870
+ m_connman.PushMessage (&pfrom, msgMaker.Make (NetMsgType::SENDCMPCT, /* high_bandwidth=*/ false , /* version=*/ CMPCTBLOCKS_VERSION));
2874
2871
}
2875
2872
pfrom.fSuccessfullyConnected = true ;
2876
2873
return ;
0 commit comments