aboutsummaryrefslogtreecommitdiff
path: root/src/net_processing.cpp
diff options
context:
space:
mode:
authorSjors Provoost <sjors@sprovoost.nl>2021-12-10 20:12:05 +0700
committerSjors Provoost <sjors@sprovoost.nl>2021-12-24 16:29:04 +0100
commit923312fbf6a89efde1739da0b7209694d4f892ba (patch)
tree886d6d648912f5cd68ba6ffe400ec4d81945f643 /src/net_processing.cpp
parent34d5399211eeb61e7e7961c301fb2ddea8aa3f6a (diff)
downloadbitcoin-923312fbf6a89efde1739da0b7209694d4f892ba.tar.xz
rpc: use peer_id, block_hash for FetchBlock
Diffstat (limited to 'src/net_processing.cpp')
-rw-r--r--src/net_processing.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index b7b1c828d4..5047ba7f30 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -312,7 +312,7 @@ public:
/** Implement PeerManager */
void StartScheduledTasks(CScheduler& scheduler) override;
void CheckForStaleTipAndEvictPeers() override;
- std::optional<std::string> FetchBlock(NodeId id, const CBlockIndex& block_index) override;
+ std::optional<std::string> FetchBlock(NodeId peer_id, const CBlockIndex& block_index) override;
bool GetNodeStateStats(NodeId nodeid, CNodeStateStats& stats) const override;
bool IgnoresIncomingTxs() override { return m_ignore_incoming_txs; }
void SendPings() override;
@@ -1428,14 +1428,14 @@ bool PeerManagerImpl::BlockRequestAllowed(const CBlockIndex* pindex)
(GetBlockProofEquivalentTime(*pindexBestHeader, *pindex, *pindexBestHeader, m_chainparams.GetConsensus()) < STALE_RELAY_AGE_LIMIT);
}
-std::optional<std::string> PeerManagerImpl::FetchBlock(NodeId id, const CBlockIndex& block_index)
+std::optional<std::string> PeerManagerImpl::FetchBlock(NodeId peer_id, const CBlockIndex& block_index)
{
if (fImporting) return "Importing...";
if (fReindex) return "Reindexing...";
LOCK(cs_main);
// Ensure this peer exists and hasn't been disconnected
- CNodeState* state = State(id);
+ CNodeState* state = State(peer_id);
if (state == nullptr) return "Peer does not exist";
// Ignore pre-segwit peers
if (!state->fHaveWitness) return "Pre-SegWit peer";
@@ -1443,23 +1443,23 @@ std::optional<std::string> PeerManagerImpl::FetchBlock(NodeId id, const CBlockIn
// Mark block as in-flight unless it already is (for this peer).
// If a block was already in-flight for a different peer, its BLOCKTXN
// response will be dropped.
- if (!BlockRequested(id, block_index)) return "Already requested from this peer";
+ if (!BlockRequested(peer_id, block_index)) return "Already requested from this peer";
// Construct message to request the block
const uint256& hash{block_index.GetBlockHash()};
std::vector<CInv> invs{CInv(MSG_BLOCK | MSG_WITNESS_FLAG, hash)};
// Send block request message to the peer
- bool success = m_connman.ForNode(id, [this, &invs](CNode* node) {
+ bool success = m_connman.ForNode(peer_id, [this, &invs](CNode* node) {
const CNetMsgMaker msgMaker(node->GetCommonVersion());
this->m_connman.PushMessage(node, msgMaker.Make(NetMsgType::GETDATA, invs));
return true;
});
- if (!success) return "Node not fully connected";
+ if (!success) return "Peer not fully connected";
LogPrint(BCLog::NET, "Requesting block %s from peer=%d\n",
- hash.ToString(), id);
+ hash.ToString(), peer_id);
return std::nullopt;
}