|
|
|
@ -497,7 +497,7 @@ void MaybeSetPeerAsAnnouncingHeaderAndIDs(const CNodeState* nodestate, CNode* pf
@@ -497,7 +497,7 @@ void MaybeSetPeerAsAnnouncingHeaderAndIDs(const CNodeState* nodestate, CNode* pf
|
|
|
|
|
if (nodeid == pfrom->GetId()) |
|
|
|
|
return; |
|
|
|
|
bool fAnnounceUsingCMPCTBLOCK = false; |
|
|
|
|
uint64_t nCMPCTBLOCKVersion = (pfrom->GetLocalServices() & NODE_WITNESS) ? 2 : 1; |
|
|
|
|
uint64_t nCMPCTBLOCKVersion = (nLocalServices & NODE_WITNESS) ? 2 : 1; |
|
|
|
|
if (lNodesAnnouncingHeaderAndIDs.size() >= 3) { |
|
|
|
|
// As per BIP152, we only get 3 of our peers to announce
|
|
|
|
|
// blocks using compact encodings.
|
|
|
|
@ -4912,7 +4912,7 @@ void static ProcessGetData(CNode* pfrom, const Consensus::Params& consensusParam
@@ -4912,7 +4912,7 @@ void static ProcessGetData(CNode* pfrom, const Consensus::Params& consensusParam
|
|
|
|
|
|
|
|
|
|
uint32_t GetFetchFlags(CNode* pfrom, CBlockIndex* pprev, const Consensus::Params& chainparams) { |
|
|
|
|
uint32_t nFetchFlags = 0; |
|
|
|
|
if (IsWitnessEnabled(pprev, chainparams) && State(pfrom->GetId())->fHaveWitness) { |
|
|
|
|
if ((nLocalServices & NODE_WITNESS) && State(pfrom->GetId())->fHaveWitness) { |
|
|
|
|
nFetchFlags |= MSG_WITNESS_FLAG; |
|
|
|
|
} |
|
|
|
|
return nFetchFlags; |
|
|
|
@ -5123,7 +5123,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
@@ -5123,7 +5123,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
|
|
|
|
// they may wish to request compact blocks from us
|
|
|
|
|
bool fAnnounceUsingCMPCTBLOCK = false; |
|
|
|
|
uint64_t nCMPCTBLOCKVersion = 2; |
|
|
|
|
if (pfrom->GetLocalServices() & NODE_WITNESS) |
|
|
|
|
if (nLocalServices & NODE_WITNESS) |
|
|
|
|
pfrom->PushMessage(NetMsgType::SENDCMPCT, fAnnounceUsingCMPCTBLOCK, nCMPCTBLOCKVersion); |
|
|
|
|
nCMPCTBLOCKVersion = 1; |
|
|
|
|
pfrom->PushMessage(NetMsgType::SENDCMPCT, fAnnounceUsingCMPCTBLOCK, nCMPCTBLOCKVersion); |
|
|
|
@ -5207,7 +5207,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
@@ -5207,7 +5207,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
|
|
|
|
bool fAnnounceUsingCMPCTBLOCK = false; |
|
|
|
|
uint64_t nCMPCTBLOCKVersion = 0; |
|
|
|
|
vRecv >> fAnnounceUsingCMPCTBLOCK >> nCMPCTBLOCKVersion; |
|
|
|
|
if (nCMPCTBLOCKVersion == 1 || ((pfrom->GetLocalServices() & NODE_WITNESS) && nCMPCTBLOCKVersion == 2)) { |
|
|
|
|
if (nCMPCTBLOCKVersion == 1 || ((nLocalServices & NODE_WITNESS) && nCMPCTBLOCKVersion == 2)) { |
|
|
|
|
LOCK(cs_main); |
|
|
|
|
// fProvidesHeaderAndIDs is used to "lock in" version of compact blocks we send (fWantsCmpctWitness)
|
|
|
|
|
if (!State(pfrom->GetId())->fProvidesHeaderAndIDs) { |
|
|
|
@ -5217,7 +5217,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
@@ -5217,7 +5217,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
|
|
|
|
if (State(pfrom->GetId())->fWantsCmpctWitness == (nCMPCTBLOCKVersion == 2)) // ignore later version announces
|
|
|
|
|
State(pfrom->GetId())->fPreferHeaderAndIDs = fAnnounceUsingCMPCTBLOCK; |
|
|
|
|
if (!State(pfrom->GetId())->fSupportsDesiredCmpctVersion) { |
|
|
|
|
if (pfrom->GetLocalServices() & NODE_WITNESS) |
|
|
|
|
if (nLocalServices & NODE_WITNESS) |
|
|
|
|
State(pfrom->GetId())->fSupportsDesiredCmpctVersion = (nCMPCTBLOCKVersion == 2); |
|
|
|
|
else |
|
|
|
|
State(pfrom->GetId())->fSupportsDesiredCmpctVersion = (nCMPCTBLOCKVersion == 1); |
|
|
|
|