Created
July 9, 2019 19:04
-
-
Save jamesob/b68f11b33a8506ddc6d0a126510486e0 to your computer and use it in GitHub Desktop.
Add blocksonly to getpeerinfo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/net.cpp b/src/net.cpp | |
index d4bca2ab4e..0d78206662 100644 | |
--- a/src/net.cpp | |
+++ b/src/net.cpp | |
@@ -500,6 +500,9 @@ void CNode::copyStats(CNodeStats &stats) | |
if (m_tx_relay != nullptr) { | |
LOCK(m_tx_relay->cs_filter); | |
stats.fRelayTxes = m_tx_relay->fRelayTxes; | |
+ stats.m_is_blocks_only = false; | |
+ } else { | |
+ stats.m_is_blocks_only = true; | |
} | |
X(nLastSend); | |
X(nLastRecv); | |
diff --git a/src/net.h b/src/net.h | |
index 2def40970e..c8ffd9f2e3 100644 | |
--- a/src/net.h | |
+++ b/src/net.h | |
@@ -571,6 +571,8 @@ public: | |
CAddress addr; | |
// Bind address of our side of the connection | |
CAddress addrBind; | |
+ // True if this connection only transmits blocks | |
+ bool m_is_blocks_only; | |
}; | |
diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp | |
index e49c3e031f..e0c9df4302 100644 | |
--- a/src/rpc/net.cpp | |
+++ b/src/rpc/net.cpp | |
@@ -103,6 +103,7 @@ static UniValue getpeerinfo(const JSONRPCRequest& request) | |
" \"subver\": \"/Satoshi:0.8.5/\", (string) The string version\n" | |
" \"inbound\": true|false, (boolean) Inbound (true) or Outbound (false)\n" | |
" \"addnode\": true|false, (boolean) Whether connection was due to addnode/-connect or if it was an automatic/inbound connection\n" | |
+ " \"blocksonly\": true|false, (boolean) Whether connection only transmits blocks\n" | |
" \"startingheight\": n, (numeric) The starting height (block) of the peer\n" | |
" \"banscore\": n, (numeric) The ban score\n" | |
" \"synced_headers\": n, (numeric) The last header we have in common with this peer\n" | |
@@ -174,6 +175,7 @@ static UniValue getpeerinfo(const JSONRPCRequest& request) | |
obj.pushKV("subver", stats.cleanSubVer); | |
obj.pushKV("inbound", stats.fInbound); | |
obj.pushKV("addnode", stats.m_manual_connection); | |
+ obj.pushKV("blocksonly", stats.m_is_blocks_only); | |
obj.pushKV("startingheight", stats.nStartingHeight); | |
if (fStateStats) { | |
obj.pushKV("banscore", statestats.nMisbehavior); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment