diff --git a/src/net_processing.h b/src/net_processing.h --- a/src/net_processing.h +++ b/src/net_processing.h @@ -61,13 +61,13 @@ * the header. * * @param[in] config The global config - * @param[in] id The peer id + * @param[in] peer_id The peer id * @param[in] block_index The block index * @returns std::nullopt if a request was successfully made, otherwise an * error message */ virtual std::optional - FetchBlock(const Config &config, NodeId id, + FetchBlock(const Config &config, NodeId peer_id, const CBlockIndex &block_index) = 0; /** Begin running background tasks, should only be called once */ diff --git a/src/net_processing.cpp b/src/net_processing.cpp --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -495,7 +495,7 @@ void StartScheduledTasks(CScheduler &scheduler) override; void CheckForStaleTipAndEvictPeers() override; std::optional - FetchBlock(const Config &config, NodeId id, + FetchBlock(const Config &config, NodeId peer_id, const CBlockIndex &block_index) override; bool GetNodeStateStats(NodeId nodeid, CNodeStateStats &stats) const override; @@ -2063,7 +2063,7 @@ } std::optional -PeerManagerImpl::FetchBlock(const Config &config, NodeId id, +PeerManagerImpl::FetchBlock(const Config &config, NodeId peer_id, const CBlockIndex &block_index) { if (fImporting) { return "Importing..."; @@ -2074,14 +2074,14 @@ 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"; } // 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(config, id, block_index)) { + if (!BlockRequested(config, peer_id, block_index)) { return "Already requested from this peer"; } @@ -2090,7 +2090,7 @@ const std::vector invs{CInv(MSG_BLOCK, hash)}; // Send block request message to the peer - if (!m_connman.ForNode(id, [this, &invs](CNode *node) { + if (!m_connman.ForNode(peer_id, [this, &invs](CNode *node) { const CNetMsgMaker msgMaker(node->GetCommonVersion()); this->m_connman.PushMessage( node, msgMaker.Make(NetMsgType::GETDATA, invs)); @@ -2100,7 +2100,7 @@ } LogPrint(BCLog::NET, "Requesting block %s from peer=%d\n", hash.ToString(), - id); + peer_id); return std::nullopt; } diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -888,9 +888,9 @@ "scheduled.", { {"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, - "The block hash"}, - {"nodeid", RPCArg::Type::NUM, RPCArg::Optional::NO, - "The node ID (see getpeerinfo for node IDs)"}, + "The block hash to try to fetch"}, + {"peer_id", RPCArg::Type::NUM, RPCArg::Optional::NO, + "The peer to fetch it from (see getpeerinfo for peer IDs)"}, }, RPCResult{RPCResult::Type::OBJ_EMPTY, "", /*optional=*/false, "", {}}, RPCExamples{HelpExampleCli("getblockfrompeer", @@ -905,11 +905,13 @@ ChainstateManager &chainman = EnsureChainman(node); PeerManager &peerman = EnsurePeerman(node); - const BlockHash hash{ParseHashV(request.params[0], "hash")}; - const NodeId nodeid{request.params[1].get_int64()}; + const BlockHash block_hash{ + ParseHashV(request.params[0], "blockhash")}; + const NodeId peer_id{request.params[1].get_int64()}; const CBlockIndex *const index = WITH_LOCK( - cs_main, return chainman.m_blockman.LookupBlockIndex(hash);); + cs_main, + return chainman.m_blockman.LookupBlockIndex(block_hash);); if (!index) { throw JSONRPCError(RPC_MISC_ERROR, "Block header missing"); @@ -919,7 +921,7 @@ throw JSONRPCError(RPC_MISC_ERROR, "Block already downloaded"); } - if (const auto err{peerman.FetchBlock(config, nodeid, *index)}) { + if (const auto err{peerman.FetchBlock(config, peer_id, *index)}) { throw JSONRPCError(RPC_MISC_ERROR, err.value()); } return UniValue::VOBJ; diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -49,7 +49,7 @@ {"getbalance", 1, "minconf"}, {"getbalance", 2, "include_watchonly"}, {"getbalance", 3, "avoid_reuse"}, - {"getblockfrompeer", 1, "nodeid"}, + {"getblockfrompeer", 1, "peer_id"}, {"getblockhash", 0, "height"}, {"waitforblockheight", 0, "height"}, {"waitforblockheight", 1, "timeout"},