Skip to content

Commit c853ef0

Browse files
committed
scripted-diff: rename vBlockHashesToAnnounce and vInventoryBlockToSend
-BEGIN VERIFY SCRIPT- sed -i 's/vBlockHashesToAnnounce/m_blocks_for_headers_relay/g' src/net_processing.* sed -i 's/vInventoryBlockToSend/m_blocks_for_inv_relay/g' src/net_processing.* -END VERIFY SCRIPT-
1 parent 53b7ac1 commit c853ef0

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

src/net_processing.cpp

+14-14
Original file line numberDiff line numberDiff line change
@@ -1321,7 +1321,7 @@ void PeerManager::UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockInde
13211321
Peer& peer = *it.second;
13221322
LOCK(peer.m_block_inv_mutex);
13231323
for (const uint256& hash : reverse_iterate(vHashes)) {
1324-
peer.vBlockHashesToAnnounce.push_back(hash);
1324+
peer.m_blocks_for_headers_relay.push_back(hash);
13251325
}
13261326
}
13271327
}
@@ -2799,7 +2799,7 @@ void PeerManager::ProcessMessage(CNode& pfrom, const std::string& msg_type, CDat
27992799
LogPrint(BCLog::NET, " getblocks stopping, pruned or too old block at %d %s\n", pindex->nHeight, pindex->GetBlockHash().ToString());
28002800
break;
28012801
}
2802-
WITH_LOCK(peer->m_block_inv_mutex, peer->vInventoryBlockToSend.push_back(pindex->GetBlockHash()));
2802+
WITH_LOCK(peer->m_block_inv_mutex, peer->m_blocks_for_inv_relay.push_back(pindex->GetBlockHash()));
28032803
if (--nLimit <= 0)
28042804
{
28052805
// When this block is requested, we'll send an inv that'll
@@ -4225,8 +4225,8 @@ bool PeerManager::SendMessages(CNode* pto)
42254225
LOCK(peer->m_block_inv_mutex);
42264226
std::vector<CBlock> vHeaders;
42274227
bool fRevertToInv = ((!state.fPreferHeaders &&
4228-
(!state.fPreferHeaderAndIDs || peer->vBlockHashesToAnnounce.size() > 1)) ||
4229-
peer->vBlockHashesToAnnounce.size() > MAX_BLOCKS_TO_ANNOUNCE);
4228+
(!state.fPreferHeaderAndIDs || peer->m_blocks_for_headers_relay.size() > 1)) ||
4229+
peer->m_blocks_for_headers_relay.size() > MAX_BLOCKS_TO_ANNOUNCE);
42304230
const CBlockIndex *pBestIndex = nullptr; // last header queued for delivery
42314231
ProcessBlockAvailability(pto->GetId()); // ensure pindexBestKnownBlock is up-to-date
42324232

@@ -4235,7 +4235,7 @@ bool PeerManager::SendMessages(CNode* pto)
42354235
// Try to find first header that our peer doesn't have, and
42364236
// then send all headers past that one. If we come across any
42374237
// headers that aren't on ::ChainActive(), give up.
4238-
for (const uint256& hash : peer->vBlockHashesToAnnounce) {
4238+
for (const uint256& hash : peer->m_blocks_for_headers_relay) {
42394239
const CBlockIndex* pindex = LookupBlockIndex(hash);
42404240
assert(pindex);
42414241
if (::ChainActive()[pindex->nHeight] != pindex) {
@@ -4252,7 +4252,7 @@ bool PeerManager::SendMessages(CNode* pto)
42524252
// which should be caught by the prior check), but one
42534253
// way this could happen is by using invalidateblock /
42544254
// reconsiderblock repeatedly on the tip, causing it to
4255-
// be added multiple times to vBlockHashesToAnnounce.
4255+
// be added multiple times to m_blocks_for_headers_relay.
42564256
// Robustly deal with this rare situation by reverting
42574257
// to an inv.
42584258
fRevertToInv = true;
@@ -4324,10 +4324,10 @@ bool PeerManager::SendMessages(CNode* pto)
43244324
}
43254325
if (fRevertToInv) {
43264326
// If falling back to using an inv, just try to inv the tip.
4327-
// The last entry in vBlockHashesToAnnounce was our tip at some point
4327+
// The last entry in m_blocks_for_headers_relay was our tip at some point
43284328
// in the past.
4329-
if (!peer->vBlockHashesToAnnounce.empty()) {
4330-
const uint256& hashToAnnounce = peer->vBlockHashesToAnnounce.back();
4329+
if (!peer->m_blocks_for_headers_relay.empty()) {
4330+
const uint256& hashToAnnounce = peer->m_blocks_for_headers_relay.back();
43314331
const CBlockIndex* pindex = LookupBlockIndex(hashToAnnounce);
43324332
assert(pindex);
43334333

@@ -4341,13 +4341,13 @@ bool PeerManager::SendMessages(CNode* pto)
43414341

43424342
// If the peer's chain has this block, don't inv it back.
43434343
if (!PeerHasHeader(&state, pindex)) {
4344-
peer->vInventoryBlockToSend.push_back(hashToAnnounce);
4344+
peer->m_blocks_for_inv_relay.push_back(hashToAnnounce);
43454345
LogPrint(BCLog::NET, "%s: sending inv peer=%d hash=%s\n", __func__,
43464346
pto->GetId(), hashToAnnounce.ToString());
43474347
}
43484348
}
43494349
}
4350-
peer->vBlockHashesToAnnounce.clear();
4350+
peer->m_blocks_for_headers_relay.clear();
43514351
}
43524352

43534353
//
@@ -4356,17 +4356,17 @@ bool PeerManager::SendMessages(CNode* pto)
43564356
std::vector<CInv> vInv;
43574357
{
43584358
LOCK(peer->m_block_inv_mutex);
4359-
vInv.reserve(std::max<size_t>(peer->vInventoryBlockToSend.size(), INVENTORY_BROADCAST_MAX));
4359+
vInv.reserve(std::max<size_t>(peer->m_blocks_for_inv_relay.size(), INVENTORY_BROADCAST_MAX));
43604360

43614361
// Add blocks
4362-
for (const uint256& hash : peer->vInventoryBlockToSend) {
4362+
for (const uint256& hash : peer->m_blocks_for_inv_relay) {
43634363
vInv.push_back(CInv(MSG_BLOCK, hash));
43644364
if (vInv.size() == MAX_INV_SZ) {
43654365
m_connman.PushMessage(pto, msgMaker.Make(NetMsgType::INV, vInv));
43664366
vInv.clear();
43674367
}
43684368
}
4369-
peer->vInventoryBlockToSend.clear();
4369+
peer->m_blocks_for_inv_relay.clear();
43704370

43714371
if (pto->m_tx_relay != nullptr) {
43724372
LOCK(pto->m_tx_relay->cs_tx_inventory);

src/net_processing.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@ struct Peer {
6868
/** List of blocks that we'll anounce via an `inv` message.
6969
* There is no final sorting before sending, as they are always sent
7070
* immediately and in the order requested. */
71-
std::vector<uint256> vInventoryBlockToSend GUARDED_BY(m_block_inv_mutex);
71+
std::vector<uint256> m_blocks_for_inv_relay GUARDED_BY(m_block_inv_mutex);
7272
/** Unfiltered list of blocks that we'd like to announce via a `headers`
7373
* message. If we can't announce via a `headers` message, we'll fall back to
7474
* announcing via `inv`. */
75-
std::vector<uint256> vBlockHashesToAnnounce GUARDED_BY(m_block_inv_mutex);
75+
std::vector<uint256> m_blocks_for_headers_relay GUARDED_BY(m_block_inv_mutex);
7676

7777
/** This peer's reported block height when we connected */
7878
std::atomic<int> m_starting_height{-1};

0 commit comments

Comments
 (0)