@@ -678,7 +678,6 @@ class PeerManagerImpl final : public PeerManager
678
678
std::shared_ptr<const CBlock> m_most_recent_block GUARDED_BY (m_most_recent_block_mutex);
679
679
std::shared_ptr<const CBlockHeaderAndShortTxIDs> m_most_recent_compact_block GUARDED_BY (m_most_recent_block_mutex);
680
680
uint256 m_most_recent_block_hash GUARDED_BY (m_most_recent_block_mutex);
681
- bool m_most_recent_compact_block_has_witnesses GUARDED_BY (m_most_recent_block_mutex){false };
682
681
683
682
/* * Height of the highest block announced using BIP 152 high-bandwidth mode. */
684
683
int m_highest_fast_announce{0 };
@@ -1630,7 +1629,8 @@ void PeerManagerImpl::NewPoWValidBlock(const CBlockIndex *pindex, const std::sha
1630
1629
return ;
1631
1630
m_highest_fast_announce = pindex->nHeight ;
1632
1631
1633
- bool fWitnessEnabled = DeploymentActiveAt (*pindex, m_chainman, Consensus::DEPLOYMENT_SEGWIT);
1632
+ if (!DeploymentActiveAt (*pindex, m_chainman, Consensus::DEPLOYMENT_SEGWIT)) return ;
1633
+
1634
1634
uint256 hashBlock (pblock->GetHash ());
1635
1635
const std::shared_future<CSerializedNetMsg> lazy_ser{
1636
1636
std::async (std::launch::deferred, [&] { return msgMaker.Make (NetMsgType::CMPCTBLOCK, *pcmpctblock); })};
@@ -1640,10 +1640,9 @@ void PeerManagerImpl::NewPoWValidBlock(const CBlockIndex *pindex, const std::sha
1640
1640
m_most_recent_block_hash = hashBlock;
1641
1641
m_most_recent_block = pblock;
1642
1642
m_most_recent_compact_block = pcmpctblock;
1643
- m_most_recent_compact_block_has_witnesses = fWitnessEnabled ;
1644
1643
}
1645
1644
1646
- m_connman.ForEachNode ([this , pindex, fWitnessEnabled , &lazy_ser, &hashBlock](CNode* pnode) EXCLUSIVE_LOCKS_REQUIRED (::cs_main) {
1645
+ m_connman.ForEachNode ([this , pindex, &lazy_ser, &hashBlock](CNode* pnode) EXCLUSIVE_LOCKS_REQUIRED (::cs_main) {
1647
1646
AssertLockHeld (::cs_main);
1648
1647
1649
1648
if (pnode->GetCommonVersion () < INVALID_CB_NO_BAN_VERSION || pnode->fDisconnect )
@@ -1847,12 +1846,10 @@ void PeerManagerImpl::ProcessGetBlockData(CNode& pfrom, Peer& peer, const CInv&
1847
1846
{
1848
1847
std::shared_ptr<const CBlock> a_recent_block;
1849
1848
std::shared_ptr<const CBlockHeaderAndShortTxIDs> a_recent_compact_block;
1850
- bool fWitnessesPresentInARecentCompactBlock ;
1851
1849
{
1852
1850
LOCK (m_most_recent_block_mutex);
1853
1851
a_recent_block = m_most_recent_block;
1854
1852
a_recent_compact_block = m_most_recent_compact_block;
1855
- fWitnessesPresentInARecentCompactBlock = m_most_recent_compact_block_has_witnesses;
1856
1853
}
1857
1854
1858
1855
bool need_activate_chain = false ;
@@ -1965,17 +1962,15 @@ void PeerManagerImpl::ProcessGetBlockData(CNode& pfrom, Peer& peer, const CInv&
1965
1962
// they won't have a useful mempool to match against a compact block,
1966
1963
// and we don't feel like constructing the object for them, so
1967
1964
// instead we respond with the full, non-compact block.
1968
- bool fPeerWantsWitness = State (pfrom.GetId ())->m_provides_cmpctblocks ;
1969
- int nSendFlags = fPeerWantsWitness ? 0 : SERIALIZE_TRANSACTION_NO_WITNESS;
1970
1965
if (CanDirectFetch () && pindex->nHeight >= m_chainman.ActiveChain ().Height () - MAX_CMPCTBLOCK_DEPTH) {
1971
- if (( fPeerWantsWitness || ! fWitnessesPresentInARecentCompactBlock ) && a_recent_compact_block && a_recent_compact_block->header .GetHash () == pindex->GetBlockHash ()) {
1972
- m_connman.PushMessage (&pfrom, msgMaker.Make (nSendFlags, NetMsgType::CMPCTBLOCK, *a_recent_compact_block));
1966
+ if (a_recent_compact_block && a_recent_compact_block->header .GetHash () == pindex->GetBlockHash ()) {
1967
+ m_connman.PushMessage (&pfrom, msgMaker.Make (NetMsgType::CMPCTBLOCK, *a_recent_compact_block));
1973
1968
} else {
1974
- CBlockHeaderAndShortTxIDs cmpctblock (*pblock, fPeerWantsWitness );
1975
- m_connman.PushMessage (&pfrom, msgMaker.Make (nSendFlags, NetMsgType::CMPCTBLOCK, cmpctblock));
1969
+ CBlockHeaderAndShortTxIDs cmpctblock (*pblock, true );
1970
+ m_connman.PushMessage (&pfrom, msgMaker.Make (NetMsgType::CMPCTBLOCK, cmpctblock));
1976
1971
}
1977
1972
} else {
1978
- m_connman.PushMessage (&pfrom, msgMaker.Make (nSendFlags, NetMsgType::BLOCK, *pblock));
1973
+ m_connman.PushMessage (&pfrom, msgMaker.Make (NetMsgType::BLOCK, *pblock));
1979
1974
}
1980
1975
}
1981
1976
}
@@ -2134,10 +2129,9 @@ void PeerManagerImpl::SendBlockTransactions(CNode& pfrom, const CBlock& block, c
2134
2129
}
2135
2130
resp.txn [i] = block.vtx [req.indexes [i]];
2136
2131
}
2137
- LOCK (cs_main);
2132
+
2138
2133
const CNetMsgMaker msgMaker (pfrom.GetCommonVersion ());
2139
- int nSendFlags = State (pfrom.GetId ())->m_provides_cmpctblocks ? 0 : SERIALIZE_TRANSACTION_NO_WITNESS;
2140
- m_connman.PushMessage (&pfrom, msgMaker.Make (nSendFlags, NetMsgType::BLOCKTXN, resp));
2134
+ m_connman.PushMessage (&pfrom, msgMaker.Make (NetMsgType::BLOCKTXN, resp));
2141
2135
}
2142
2136
2143
2137
void PeerManagerImpl::ProcessHeadersMessage (CNode& pfrom, const Peer& peer,
@@ -3230,9 +3224,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
3230
3224
// expensive disk reads, because it will require the peer to
3231
3225
// actually receive all the data read from disk over the network.
3232
3226
LogPrint (BCLog::NET, " Peer %d sent us a getblocktxn for a block > %i deep\n " , pfrom.GetId (), MAX_BLOCKTXN_DEPTH);
3233
- CInv inv;
3234
- WITH_LOCK (cs_main, inv.type = State (pfrom.GetId ())->m_provides_cmpctblocks ? MSG_WITNESS_BLOCK : MSG_BLOCK);
3235
- inv.hash = req.blockhash ;
3227
+ CInv inv{MSG_WITNESS_BLOCK, req.blockhash };
3236
3228
WITH_LOCK (peer->m_getdata_requests_mutex , peer->m_getdata_requests .push_back (inv));
3237
3229
// The message processing loop will go around again (without pausing) and we'll respond then
3238
3230
return ;
@@ -3607,12 +3599,6 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
3607
3599
return ;
3608
3600
}
3609
3601
3610
- if (DeploymentActiveAt (*pindex, m_chainman, Consensus::DEPLOYMENT_SEGWIT) && !nodestate->m_provides_cmpctblocks ) {
3611
- // Don't bother trying to process compact blocks from v1 peers
3612
- // after segwit activates.
3613
- return ;
3614
- }
3615
-
3616
3602
// We want to be a bit conservative just to be extra careful about DoS
3617
3603
// possibilities in compact block processing...
3618
3604
if (pindex->nHeight <= m_chainman.ActiveChain ().Height () + 2 ) {
0 commit comments