Skip to content

Commit 30c3a01

Browse files
committed
[net processing] fPreferHeaderAndIDs implies fProvidesHeaderAndIDs
Remove all if(fProvidesHeaderAndIDs) conditionals inside if(fPreferHeaderAndIDs) conditionals.
1 parent b486f72 commit 30c3a01

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

src/net_processing.cpp

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1654,8 +1654,7 @@ void PeerManagerImpl::NewPoWValidBlock(const CBlockIndex *pindex, const std::sha
16541654
CNodeState &state = *State(pnode->GetId());
16551655
// If the peer has, or we announced to them the previous block already,
16561656
// but we don't think they have this one, go ahead and announce it
1657-
if (state.fPreferHeaderAndIDs && (!fWitnessEnabled || state.fProvidesHeaderAndIDs) &&
1658-
!PeerHasHeader(&state, pindex) && PeerHasHeader(&state, pindex->pprev)) {
1657+
if (state.fPreferHeaderAndIDs && !PeerHasHeader(&state, pindex) && PeerHasHeader(&state, pindex->pprev)) {
16591658

16601659
LogPrint(BCLog::NET, "%s sending header-and-ids %s to peer=%d\n", "PeerManager::NewPoWValidBlock",
16611660
hashBlock.ToString(), pnode->GetId());
@@ -4767,27 +4766,20 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
47674766
LogPrint(BCLog::NET, "%s sending header-and-ids %s to peer=%d\n", __func__,
47684767
vHeaders.front().GetHash().ToString(), pto->GetId());
47694768

4770-
int nSendFlags = state.fProvidesHeaderAndIDs ? 0 : SERIALIZE_TRANSACTION_NO_WITNESS;
4771-
47724769
bool fGotBlockFromCache = false;
47734770
{
47744771
LOCK(m_most_recent_block_mutex);
47754772
if (m_most_recent_block_hash == pBestIndex->GetBlockHash()) {
4776-
if (state.fProvidesHeaderAndIDs || !m_most_recent_compact_block_has_witnesses)
4777-
m_connman.PushMessage(pto, msgMaker.Make(nSendFlags, NetMsgType::CMPCTBLOCK, *m_most_recent_compact_block));
4778-
else {
4779-
CBlockHeaderAndShortTxIDs cmpctblock(*m_most_recent_block, state.fProvidesHeaderAndIDs);
4780-
m_connman.PushMessage(pto, msgMaker.Make(nSendFlags, NetMsgType::CMPCTBLOCK, cmpctblock));
4781-
}
4773+
m_connman.PushMessage(pto, msgMaker.Make(NetMsgType::CMPCTBLOCK, *m_most_recent_compact_block));
47824774
fGotBlockFromCache = true;
47834775
}
47844776
}
47854777
if (!fGotBlockFromCache) {
47864778
CBlock block;
47874779
bool ret = ReadBlockFromDisk(block, pBestIndex, consensusParams);
47884780
assert(ret);
4789-
CBlockHeaderAndShortTxIDs cmpctblock(block, state.fProvidesHeaderAndIDs);
4790-
m_connman.PushMessage(pto, msgMaker.Make(nSendFlags, NetMsgType::CMPCTBLOCK, cmpctblock));
4781+
CBlockHeaderAndShortTxIDs cmpctblock(block, true);
4782+
m_connman.PushMessage(pto, msgMaker.Make(NetMsgType::CMPCTBLOCK, cmpctblock));
47914783
}
47924784
state.pindexBestHeaderSent = pBestIndex;
47934785
} else if (state.fPreferHeaders) {

0 commit comments

Comments
 (0)