@@ -375,8 +375,6 @@ struct CNodeState {
375
375
bool fProvidesHeaderAndIDs {false };
376
376
// ! Whether this peer can give us witnesses
377
377
bool fHaveWitness {false };
378
- // ! Whether this peer wants witnesses in cmpctblocks/blocktxns
379
- bool fWantsCmpctWitness {false };
380
378
381
379
/* * State used to enforce CHAIN_SYNC_TIMEOUT and EXTRA_PEER_CHECK_INTERVAL logic.
382
380
*
@@ -1656,7 +1654,7 @@ void PeerManagerImpl::NewPoWValidBlock(const CBlockIndex *pindex, const std::sha
1656
1654
CNodeState &state = *State (pnode->GetId ());
1657
1655
// If the peer has, or we announced to them the previous block already,
1658
1656
// but we don't think they have this one, go ahead and announce it
1659
- if (state.fPreferHeaderAndIDs && (!fWitnessEnabled || state.fWantsCmpctWitness ) &&
1657
+ if (state.fPreferHeaderAndIDs && (!fWitnessEnabled || state.fProvidesHeaderAndIDs ) &&
1660
1658
!PeerHasHeader (&state, pindex) && PeerHasHeader (&state, pindex->pprev )) {
1661
1659
1662
1660
LogPrint (BCLog::NET, " %s sending header-and-ids %s to peer=%d\n " , " PeerManager::NewPoWValidBlock" ,
@@ -1970,7 +1968,7 @@ void PeerManagerImpl::ProcessGetBlockData(CNode& pfrom, Peer& peer, const CInv&
1970
1968
// they won't have a useful mempool to match against a compact block,
1971
1969
// and we don't feel like constructing the object for them, so
1972
1970
// instead we respond with the full, non-compact block.
1973
- bool fPeerWantsWitness = State (pfrom.GetId ())->fWantsCmpctWitness ;
1971
+ bool fPeerWantsWitness = State (pfrom.GetId ())->fProvidesHeaderAndIDs ;
1974
1972
int nSendFlags = fPeerWantsWitness ? 0 : SERIALIZE_TRANSACTION_NO_WITNESS;
1975
1973
if (CanDirectFetch () && pindex->nHeight >= m_chainman.ActiveChain ().Height () - MAX_CMPCTBLOCK_DEPTH) {
1976
1974
if ((fPeerWantsWitness || !fWitnessesPresentInARecentCompactBlock ) && a_recent_compact_block && a_recent_compact_block->header .GetHash () == pindex->GetBlockHash ()) {
@@ -2141,7 +2139,7 @@ void PeerManagerImpl::SendBlockTransactions(CNode& pfrom, const CBlock& block, c
2141
2139
}
2142
2140
LOCK (cs_main);
2143
2141
const CNetMsgMaker msgMaker (pfrom.GetCommonVersion ());
2144
- int nSendFlags = State (pfrom.GetId ())->fWantsCmpctWitness ? 0 : SERIALIZE_TRANSACTION_NO_WITNESS;
2142
+ int nSendFlags = State (pfrom.GetId ())->fProvidesHeaderAndIDs ? 0 : SERIALIZE_TRANSACTION_NO_WITNESS;
2145
2143
m_connman.PushMessage (&pfrom, msgMaker.Make (nSendFlags, NetMsgType::BLOCKTXN, resp));
2146
2144
}
2147
2145
@@ -2881,12 +2879,10 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
2881
2879
if (nCMPCTBLOCKVersion != CMPCTBLOCKS_VERSION) return ;
2882
2880
2883
2881
LOCK (cs_main);
2884
- // fProvidesHeaderAndIDs is used to "lock in" version of compact blocks we send (fWantsCmpctWitness)
2885
2882
if (!State (pfrom.GetId ())->fProvidesHeaderAndIDs ) {
2886
2883
State (pfrom.GetId ())->fProvidesHeaderAndIDs = true ;
2887
- State (pfrom.GetId ())->fWantsCmpctWitness = true ;
2888
2884
}
2889
- if (State (pfrom.GetId ())->fWantsCmpctWitness ) {
2885
+ if (State (pfrom.GetId ())->fProvidesHeaderAndIDs ) {
2890
2886
State (pfrom.GetId ())->fPreferHeaderAndIDs = fAnnounceUsingCMPCTBLOCK ;
2891
2887
// save whether peer selects us as BIP152 high-bandwidth peer
2892
2888
// (receiving sendcmpct(1) signals high-bandwidth, sendcmpct(0) low-bandwidth)
@@ -3241,7 +3237,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
3241
3237
// actually receive all the data read from disk over the network.
3242
3238
LogPrint (BCLog::NET, " Peer %d sent us a getblocktxn for a block > %i deep\n " , pfrom.GetId (), MAX_BLOCKTXN_DEPTH);
3243
3239
CInv inv;
3244
- WITH_LOCK (cs_main, inv.type = State (pfrom.GetId ())->fWantsCmpctWitness ? MSG_WITNESS_BLOCK : MSG_BLOCK);
3240
+ WITH_LOCK (cs_main, inv.type = State (pfrom.GetId ())->fProvidesHeaderAndIDs ? MSG_WITNESS_BLOCK : MSG_BLOCK);
3245
3241
inv.hash = req.blockhash ;
3246
3242
WITH_LOCK (peer->m_getdata_requests_mutex , peer->m_getdata_requests .push_back (inv));
3247
3243
// The message processing loop will go around again (without pausing) and we'll respond then
@@ -4771,16 +4767,16 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
4771
4767
LogPrint (BCLog::NET, " %s sending header-and-ids %s to peer=%d\n " , __func__,
4772
4768
vHeaders.front ().GetHash ().ToString (), pto->GetId ());
4773
4769
4774
- int nSendFlags = state.fWantsCmpctWitness ? 0 : SERIALIZE_TRANSACTION_NO_WITNESS;
4770
+ int nSendFlags = state.fProvidesHeaderAndIDs ? 0 : SERIALIZE_TRANSACTION_NO_WITNESS;
4775
4771
4776
4772
bool fGotBlockFromCache = false ;
4777
4773
{
4778
4774
LOCK (m_most_recent_block_mutex);
4779
4775
if (m_most_recent_block_hash == pBestIndex->GetBlockHash ()) {
4780
- if (state.fWantsCmpctWitness || !m_most_recent_compact_block_has_witnesses)
4776
+ if (state.fProvidesHeaderAndIDs || !m_most_recent_compact_block_has_witnesses)
4781
4777
m_connman.PushMessage (pto, msgMaker.Make (nSendFlags, NetMsgType::CMPCTBLOCK, *m_most_recent_compact_block));
4782
4778
else {
4783
- CBlockHeaderAndShortTxIDs cmpctblock (*m_most_recent_block, state.fWantsCmpctWitness );
4779
+ CBlockHeaderAndShortTxIDs cmpctblock (*m_most_recent_block, state.fProvidesHeaderAndIDs );
4784
4780
m_connman.PushMessage (pto, msgMaker.Make (nSendFlags, NetMsgType::CMPCTBLOCK, cmpctblock));
4785
4781
}
4786
4782
fGotBlockFromCache = true ;
@@ -4790,7 +4786,7 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
4790
4786
CBlock block;
4791
4787
bool ret = ReadBlockFromDisk (block, pBestIndex, consensusParams);
4792
4788
assert (ret);
4793
- CBlockHeaderAndShortTxIDs cmpctblock (block, state.fWantsCmpctWitness );
4789
+ CBlockHeaderAndShortTxIDs cmpctblock (block, state.fProvidesHeaderAndIDs );
4794
4790
m_connman.PushMessage (pto, msgMaker.Make (nSendFlags, NetMsgType::CMPCTBLOCK, cmpctblock));
4795
4791
}
4796
4792
state.pindexBestHeaderSent = pBestIndex;
0 commit comments