Skip to content

Commit 4bb9ce8

Browse files
TheBlueMattlaanwj
authored andcommitted
Use cmpctblock type 2 for segwit-enabled transfer
Contains version negotiation logic by Matt Corallo and bugfixes by Suhas Daftuar. Github-Pull: #8393 Rebased-From: 6aa28ab
1 parent 890ac25 commit 4bb9ce8

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/main.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ void MaybeSetPeerAsAnnouncingHeaderAndIDs(const CNodeState* nodestate, CNode* pf
497497
if (nodeid == pfrom->GetId())
498498
return;
499499
bool fAnnounceUsingCMPCTBLOCK = false;
500-
uint64_t nCMPCTBLOCKVersion = (pfrom->GetLocalServices() & NODE_WITNESS) ? 2 : 1;
500+
uint64_t nCMPCTBLOCKVersion = (nLocalServices & NODE_WITNESS) ? 2 : 1;
501501
if (lNodesAnnouncingHeaderAndIDs.size() >= 3) {
502502
// As per BIP152, we only get 3 of our peers to announce
503503
// blocks using compact encodings.
@@ -4912,7 +4912,7 @@ void static ProcessGetData(CNode* pfrom, const Consensus::Params& consensusParam
49124912

49134913
uint32_t GetFetchFlags(CNode* pfrom, CBlockIndex* pprev, const Consensus::Params& chainparams) {
49144914
uint32_t nFetchFlags = 0;
4915-
if (IsWitnessEnabled(pprev, chainparams) && State(pfrom->GetId())->fHaveWitness) {
4915+
if ((nLocalServices & NODE_WITNESS) && State(pfrom->GetId())->fHaveWitness) {
49164916
nFetchFlags |= MSG_WITNESS_FLAG;
49174917
}
49184918
return nFetchFlags;
@@ -5123,7 +5123,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
51235123
// they may wish to request compact blocks from us
51245124
bool fAnnounceUsingCMPCTBLOCK = false;
51255125
uint64_t nCMPCTBLOCKVersion = 2;
5126-
if (pfrom->GetLocalServices() & NODE_WITNESS)
5126+
if (nLocalServices & NODE_WITNESS)
51275127
pfrom->PushMessage(NetMsgType::SENDCMPCT, fAnnounceUsingCMPCTBLOCK, nCMPCTBLOCKVersion);
51285128
nCMPCTBLOCKVersion = 1;
51295129
pfrom->PushMessage(NetMsgType::SENDCMPCT, fAnnounceUsingCMPCTBLOCK, nCMPCTBLOCKVersion);
@@ -5207,7 +5207,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
52075207
bool fAnnounceUsingCMPCTBLOCK = false;
52085208
uint64_t nCMPCTBLOCKVersion = 0;
52095209
vRecv >> fAnnounceUsingCMPCTBLOCK >> nCMPCTBLOCKVersion;
5210-
if (nCMPCTBLOCKVersion == 1 || ((pfrom->GetLocalServices() & NODE_WITNESS) && nCMPCTBLOCKVersion == 2)) {
5210+
if (nCMPCTBLOCKVersion == 1 || ((nLocalServices & NODE_WITNESS) && nCMPCTBLOCKVersion == 2)) {
52115211
LOCK(cs_main);
52125212
// fProvidesHeaderAndIDs is used to "lock in" version of compact blocks we send (fWantsCmpctWitness)
52135213
if (!State(pfrom->GetId())->fProvidesHeaderAndIDs) {
@@ -5217,7 +5217,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
52175217
if (State(pfrom->GetId())->fWantsCmpctWitness == (nCMPCTBLOCKVersion == 2)) // ignore later version announces
52185218
State(pfrom->GetId())->fPreferHeaderAndIDs = fAnnounceUsingCMPCTBLOCK;
52195219
if (!State(pfrom->GetId())->fSupportsDesiredCmpctVersion) {
5220-
if (pfrom->GetLocalServices() & NODE_WITNESS)
5220+
if (nLocalServices & NODE_WITNESS)
52215221
State(pfrom->GetId())->fSupportsDesiredCmpctVersion = (nCMPCTBLOCKVersion == 2);
52225222
else
52235223
State(pfrom->GetId())->fSupportsDesiredCmpctVersion = (nCMPCTBLOCKVersion == 1);

0 commit comments

Comments
 (0)