aboutsummaryrefslogtreecommitdiff
path: root/src/rpc/net.cpp
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2021-12-08 10:38:10 +0100
committerMarcoFalke <falke.marco@gmail.com>2021-12-08 10:39:37 +0100
commitf6013265b7f22ce63f5e5fd8700c03d56cb000c8 (patch)
treead077d2e4194df3657e5557521feadef959a1c2a /src/rpc/net.cpp
parent84d921e79c738c7959692a4e7a76327469e8cc50 (diff)
parentdce8c4c38111556ca480aa0e63c46b71f66b508f (diff)
downloadbitcoin-f6013265b7f22ce63f5e5fd8700c03d56cb000c8.tar.xz
Merge bitcoin/bitcoin#20295: rpc: getblockfrompeer
dce8c4c38111556ca480aa0e63c46b71f66b508f rpc: getblockfrompeer (Sjors Provoost) b884ababc29ce963826d8a4327ed6a5e629ff175 rpc: move Ensure* helpers to server_util.h (Sjors Provoost) Pull request description: This adds an RPC method to fetch a block directly from a peer. This can used to fetch stale blocks with lower proof of work that are normally ignored by the node (`headers-only` in `getchaintips`). Usage: ``` bitcoin-cli getblockfrompeer HASH peer_n ``` Closes #20155 Limitations: * you have to specify which peer to fetch the block from * the node must already have the header ACKs for top commit: jnewbery: ACK dce8c4c38111556ca480aa0e63c46b71f66b508f fjahr: re-ACK dce8c4c38111556ca480aa0e63c46b71f66b508f Tree-SHA512: 843ba2b7a308f640770d624d0aa3265fdc5c6ea48e8db32269b96a082b7420f7953d1d8d1ef2e6529392c7172dded9d15639fbc9c24e7bfa5cfb79e13a5498c8
Diffstat (limited to 'src/rpc/net.cpp')
-rw-r--r--src/rpc/net.cpp19
1 files changed, 1 insertions, 18 deletions
diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp
index 021e6ae320..bdcb339e14 100644
--- a/src/rpc/net.cpp
+++ b/src/rpc/net.cpp
@@ -9,7 +9,6 @@
#include <chainparams.h>
#include <clientversion.h>
#include <core_io.h>
-#include <net.h>
#include <net_permissions.h>
#include <net_processing.h>
#include <net_types.h> // For banmap_t
@@ -18,12 +17,12 @@
#include <policy/settings.h>
#include <rpc/blockchain.h>
#include <rpc/protocol.h>
+#include <rpc/server_util.h>
#include <rpc/util.h>
#include <sync.h>
#include <timedata.h>
#include <util/strencodings.h>
#include <util/string.h>
-#include <util/system.h>
#include <util/translation.h>
#include <validation.h>
#include <version.h>
@@ -42,22 +41,6 @@ const std::vector<std::string> CONNECTION_TYPE_DOC{
"feeler (short-lived automatic connection for testing addresses)"
};
-CConnman& EnsureConnman(const NodeContext& node)
-{
- if (!node.connman) {
- throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
- }
- return *node.connman;
-}
-
-PeerManager& EnsurePeerman(const NodeContext& node)
-{
- if (!node.peerman) {
- throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
- }
- return *node.peerman;
-}
-
static RPCHelpMan getconnectioncount()
{
return RPCHelpMan{"getconnectioncount",