mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-18 11:57:37 -05:00
[net processing] fPreferHeaderAndIDs implies fProvidesHeaderAndIDs
Remove all if(fProvidesHeaderAndIDs) conditionals inside if(fPreferHeaderAndIDs) conditionals.
This commit is contained in:
parent
b486f72176
commit
30c3a01874
1 changed files with 4 additions and 12 deletions
|
@ -1654,8 +1654,7 @@ void PeerManagerImpl::NewPoWValidBlock(const CBlockIndex *pindex, const std::sha
|
||||||
CNodeState &state = *State(pnode->GetId());
|
CNodeState &state = *State(pnode->GetId());
|
||||||
// If the peer has, or we announced to them the previous block already,
|
// If the peer has, or we announced to them the previous block already,
|
||||||
// but we don't think they have this one, go ahead and announce it
|
// but we don't think they have this one, go ahead and announce it
|
||||||
if (state.fPreferHeaderAndIDs && (!fWitnessEnabled || state.fProvidesHeaderAndIDs) &&
|
if (state.fPreferHeaderAndIDs && !PeerHasHeader(&state, pindex) && PeerHasHeader(&state, pindex->pprev)) {
|
||||||
!PeerHasHeader(&state, pindex) && PeerHasHeader(&state, pindex->pprev)) {
|
|
||||||
|
|
||||||
LogPrint(BCLog::NET, "%s sending header-and-ids %s to peer=%d\n", "PeerManager::NewPoWValidBlock",
|
LogPrint(BCLog::NET, "%s sending header-and-ids %s to peer=%d\n", "PeerManager::NewPoWValidBlock",
|
||||||
hashBlock.ToString(), pnode->GetId());
|
hashBlock.ToString(), pnode->GetId());
|
||||||
|
@ -4767,18 +4766,11 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
|
||||||
LogPrint(BCLog::NET, "%s sending header-and-ids %s to peer=%d\n", __func__,
|
LogPrint(BCLog::NET, "%s sending header-and-ids %s to peer=%d\n", __func__,
|
||||||
vHeaders.front().GetHash().ToString(), pto->GetId());
|
vHeaders.front().GetHash().ToString(), pto->GetId());
|
||||||
|
|
||||||
int nSendFlags = state.fProvidesHeaderAndIDs ? 0 : SERIALIZE_TRANSACTION_NO_WITNESS;
|
|
||||||
|
|
||||||
bool fGotBlockFromCache = false;
|
bool fGotBlockFromCache = false;
|
||||||
{
|
{
|
||||||
LOCK(m_most_recent_block_mutex);
|
LOCK(m_most_recent_block_mutex);
|
||||||
if (m_most_recent_block_hash == pBestIndex->GetBlockHash()) {
|
if (m_most_recent_block_hash == pBestIndex->GetBlockHash()) {
|
||||||
if (state.fProvidesHeaderAndIDs || !m_most_recent_compact_block_has_witnesses)
|
m_connman.PushMessage(pto, msgMaker.Make(NetMsgType::CMPCTBLOCK, *m_most_recent_compact_block));
|
||||||
m_connman.PushMessage(pto, msgMaker.Make(nSendFlags, NetMsgType::CMPCTBLOCK, *m_most_recent_compact_block));
|
|
||||||
else {
|
|
||||||
CBlockHeaderAndShortTxIDs cmpctblock(*m_most_recent_block, state.fProvidesHeaderAndIDs);
|
|
||||||
m_connman.PushMessage(pto, msgMaker.Make(nSendFlags, NetMsgType::CMPCTBLOCK, cmpctblock));
|
|
||||||
}
|
|
||||||
fGotBlockFromCache = true;
|
fGotBlockFromCache = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4786,8 +4778,8 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
|
||||||
CBlock block;
|
CBlock block;
|
||||||
bool ret = ReadBlockFromDisk(block, pBestIndex, consensusParams);
|
bool ret = ReadBlockFromDisk(block, pBestIndex, consensusParams);
|
||||||
assert(ret);
|
assert(ret);
|
||||||
CBlockHeaderAndShortTxIDs cmpctblock(block, state.fProvidesHeaderAndIDs);
|
CBlockHeaderAndShortTxIDs cmpctblock(block, true);
|
||||||
m_connman.PushMessage(pto, msgMaker.Make(nSendFlags, NetMsgType::CMPCTBLOCK, cmpctblock));
|
m_connman.PushMessage(pto, msgMaker.Make(NetMsgType::CMPCTBLOCK, cmpctblock));
|
||||||
}
|
}
|
||||||
state.pindexBestHeaderSent = pBestIndex;
|
state.pindexBestHeaderSent = pBestIndex;
|
||||||
} else if (state.fPreferHeaders) {
|
} else if (state.fPreferHeaders) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue