@@ -2503,6 +2503,39 @@ void PeerManager::ProcessMessage(CNode& pfrom, const std::string& msg_type, CDat
2503
2503
return ;
2504
2504
}
2505
2505
2506
+ if (msg_type == NetMsgType::SENDHEADERS) {
2507
+ LOCK (cs_main);
2508
+ State (pfrom.GetId ())->fPreferHeaders = true ;
2509
+ return ;
2510
+ }
2511
+
2512
+ if (msg_type == NetMsgType::SENDCMPCT) {
2513
+ bool fAnnounceUsingCMPCTBLOCK = false ;
2514
+ uint64_t nCMPCTBLOCKVersion = 0 ;
2515
+ vRecv >> fAnnounceUsingCMPCTBLOCK >> nCMPCTBLOCKVersion;
2516
+ if (nCMPCTBLOCKVersion == 1 || ((pfrom.GetLocalServices () & NODE_WITNESS) && nCMPCTBLOCKVersion == 2 )) {
2517
+ LOCK (cs_main);
2518
+ // fProvidesHeaderAndIDs is used to "lock in" version of compact blocks we send (fWantsCmpctWitness)
2519
+ if (!State (pfrom.GetId ())->fProvidesHeaderAndIDs ) {
2520
+ State (pfrom.GetId ())->fProvidesHeaderAndIDs = true ;
2521
+ State (pfrom.GetId ())->fWantsCmpctWitness = nCMPCTBLOCKVersion == 2 ;
2522
+ }
2523
+ if (State (pfrom.GetId ())->fWantsCmpctWitness == (nCMPCTBLOCKVersion == 2 )) { // ignore later version announces
2524
+ State (pfrom.GetId ())->fPreferHeaderAndIDs = fAnnounceUsingCMPCTBLOCK ;
2525
+ // save whether peer selects us as BIP152 high-bandwidth peer
2526
+ // (receiving sendcmpct(1) signals high-bandwidth, sendcmpct(0) low-bandwidth)
2527
+ pfrom.m_bip152_highbandwidth_from = fAnnounceUsingCMPCTBLOCK ;
2528
+ }
2529
+ if (!State (pfrom.GetId ())->fSupportsDesiredCmpctVersion ) {
2530
+ if (pfrom.GetLocalServices () & NODE_WITNESS)
2531
+ State (pfrom.GetId ())->fSupportsDesiredCmpctVersion = (nCMPCTBLOCKVersion == 2 );
2532
+ else
2533
+ State (pfrom.GetId ())->fSupportsDesiredCmpctVersion = (nCMPCTBLOCKVersion == 1 );
2534
+ }
2535
+ }
2536
+ return ;
2537
+ }
2538
+
2506
2539
// Feature negotiation of wtxidrelay must happen between VERSION and VERACK
2507
2540
// to avoid relay problems from switching after a connection is up.
2508
2541
if (msg_type == NetMsgType::WTXIDRELAY) {
@@ -2600,39 +2633,6 @@ void PeerManager::ProcessMessage(CNode& pfrom, const std::string& msg_type, CDat
2600
2633
return ;
2601
2634
}
2602
2635
2603
- if (msg_type == NetMsgType::SENDHEADERS) {
2604
- LOCK (cs_main);
2605
- State (pfrom.GetId ())->fPreferHeaders = true ;
2606
- return ;
2607
- }
2608
-
2609
- if (msg_type == NetMsgType::SENDCMPCT) {
2610
- bool fAnnounceUsingCMPCTBLOCK = false ;
2611
- uint64_t nCMPCTBLOCKVersion = 0 ;
2612
- vRecv >> fAnnounceUsingCMPCTBLOCK >> nCMPCTBLOCKVersion;
2613
- if (nCMPCTBLOCKVersion == 1 || ((pfrom.GetLocalServices () & NODE_WITNESS) && nCMPCTBLOCKVersion == 2 )) {
2614
- LOCK (cs_main);
2615
- // fProvidesHeaderAndIDs is used to "lock in" version of compact blocks we send (fWantsCmpctWitness)
2616
- if (!State (pfrom.GetId ())->fProvidesHeaderAndIDs ) {
2617
- State (pfrom.GetId ())->fProvidesHeaderAndIDs = true ;
2618
- State (pfrom.GetId ())->fWantsCmpctWitness = nCMPCTBLOCKVersion == 2 ;
2619
- }
2620
- if (State (pfrom.GetId ())->fWantsCmpctWitness == (nCMPCTBLOCKVersion == 2 )) { // ignore later version announces
2621
- State (pfrom.GetId ())->fPreferHeaderAndIDs = fAnnounceUsingCMPCTBLOCK ;
2622
- // save whether peer selects us as BIP152 high-bandwidth peer
2623
- // (receiving sendcmpct(1) signals high-bandwidth, sendcmpct(0) low-bandwidth)
2624
- pfrom.m_bip152_highbandwidth_from = fAnnounceUsingCMPCTBLOCK ;
2625
- }
2626
- if (!State (pfrom.GetId ())->fSupportsDesiredCmpctVersion ) {
2627
- if (pfrom.GetLocalServices () & NODE_WITNESS)
2628
- State (pfrom.GetId ())->fSupportsDesiredCmpctVersion = (nCMPCTBLOCKVersion == 2 );
2629
- else
2630
- State (pfrom.GetId ())->fSupportsDesiredCmpctVersion = (nCMPCTBLOCKVersion == 1 );
2631
- }
2632
- }
2633
- return ;
2634
- }
2635
-
2636
2636
if (msg_type == NetMsgType::INV) {
2637
2637
std::vector<CInv> vInv;
2638
2638
vRecv >> vInv;
0 commit comments