Skip to content

Commit 184557e

Browse files
committed
[net processing] Move hashContinue to net processing
Also rename to m_continuation_block to better communicate meaning.
1 parent c853ef0 commit 184557e

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

src/net.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -2955,7 +2955,6 @@ CNode::CNode(NodeId idIn, ServiceFlags nLocalServicesIn, int nMyStartingHeightIn
29552955
{
29562956
hSocket = hSocketIn;
29572957
addrName = addrNameIn == "" ? addr.ToStringIPPort() : addrNameIn;
2958-
hashContinue = uint256();
29592958
if (conn_type_in != ConnectionType::BLOCK_RELAY) {
29602959
m_tx_relay = MakeUnique<TxRelay>();
29612960
}

src/net.h

-1
Original file line numberDiff line numberDiff line change
@@ -993,7 +993,6 @@ class CNode
993993
mapMsgCmdSize mapRecvBytesPerMsgCmd GUARDED_BY(cs_vRecv);
994994

995995
public:
996-
uint256 hashContinue;
997996
// We selected peer as (compact blocks) high-bandwidth peer (BIP152)
998997
std::atomic<bool> m_bip152_highbandwidth_to{false};
999998
// Peer selected us as (compact blocks) high-bandwidth peer (BIP152)

src/net_processing.cpp

+5-6
Original file line numberDiff line numberDiff line change
@@ -1475,7 +1475,7 @@ static void RelayAddress(const CNode& originator,
14751475
connman.ForEachNodeThen(std::move(sortfunc), std::move(pushfunc));
14761476
}
14771477

1478-
void static ProcessGetBlockData(CNode& pfrom, const CChainParams& chainparams, const CInv& inv, CConnman& connman)
1478+
void static ProcessGetBlockData(CNode& pfrom, Peer& peer, const CChainParams& chainparams, const CInv& inv, CConnman& connman)
14791479
{
14801480
bool send = false;
14811481
std::shared_ptr<const CBlock> a_recent_block;
@@ -1616,15 +1616,14 @@ void static ProcessGetBlockData(CNode& pfrom, const CChainParams& chainparams, c
16161616
}
16171617

16181618
// Trigger the peer node to send a getblocks request for the next batch of inventory
1619-
if (inv.hash == pfrom.hashContinue)
1620-
{
1619+
if (inv.hash == peer.m_continuation_block) {
16211620
// Send immediately. This must send even if redundant,
16221621
// and we want it right after the last block so they don't
16231622
// wait for other stuff first.
16241623
std::vector<CInv> vInv;
16251624
vInv.push_back(CInv(MSG_BLOCK, ::ChainActive().Tip()->GetBlockHash()));
16261625
connman.PushMessage(&pfrom, msgMaker.Make(NetMsgType::INV, vInv));
1627-
pfrom.hashContinue.SetNull();
1626+
peer.m_continuation_block.SetNull();
16281627
}
16291628
}
16301629
}
@@ -1724,7 +1723,7 @@ void static ProcessGetData(CNode& pfrom, Peer& peer, const CChainParams& chainpa
17241723
if (it != peer.m_getdata_requests.end() && !pfrom.fPauseSend) {
17251724
const CInv &inv = *it++;
17261725
if (inv.IsGenBlkMsg()) {
1727-
ProcessGetBlockData(pfrom, chainparams, inv, connman);
1726+
ProcessGetBlockData(pfrom, peer, chainparams, inv, connman);
17281727
}
17291728
// else: If the first item on the queue is an unknown type, we erase it
17301729
// and continue processing the queue on the next call.
@@ -2805,7 +2804,7 @@ void PeerManager::ProcessMessage(CNode& pfrom, const std::string& msg_type, CDat
28052804
// When this block is requested, we'll send an inv that'll
28062805
// trigger the peer to getblocks the next batch of inventory.
28072806
LogPrint(BCLog::NET, " getblocks stopping at limit %d %s\n", pindex->nHeight, pindex->GetBlockHash().ToString());
2808-
pfrom.hashContinue = pindex->GetBlockHash();
2807+
peer->m_continuation_block = pindex->GetBlockHash();
28092808
break;
28102809
}
28112810
}

src/net_processing.h

+5
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@ struct Peer {
7676

7777
/** This peer's reported block height when we connected */
7878
std::atomic<int> m_starting_height{-1};
79+
/** The final block hash that we sent in an `inv` message to this peer.
80+
* When the peer requests this block, we send an `inv` message to trigger
81+
* the peer to request the next sequence of block hashes.
82+
* Most peers use headers-first syncing, which doesn't use this mechanism */
83+
uint256 m_continuation_block{};
7984

8085
/** Set of txids to reconsider once their parent transactions have been accepted **/
8186
std::set<uint256> m_orphan_work_set GUARDED_BY(g_cs_orphans);

0 commit comments

Comments
 (0)