changeset 23736:94901e3d8c5f

Add thin block statistics to RPC call 'getnetworkinfo' under key 'thinblockstats'.
author Simon <simon@bitcartel.com>
date Tue, 08 Mar 2016 15:14:12 -0800
parents c7833a5d5e9f
children 304b3a3add13
files src/rpcnet.cpp
diffstat 1 files changed, 20 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/rpcnet.cpp	Tue Mar 08 13:54:41 2016 -0800
+++ b/src/rpcnet.cpp	Tue Mar 08 15:14:12 2016 -0800
@@ -16,6 +16,8 @@
 #include "util.h"
 #include "utilstrencodings.h"
 #include "version.h"
+#include "thinblock.h"
+#include "unlimited.h"
 
 #include <boost/foreach.hpp>
 #include <boost/lexical_cast.hpp>
@@ -412,6 +414,20 @@
     return networks;
 }
 
+// BitcoinUnlimited BUIP010 : Start
+static UniValue GetThinBlockStats()
+{
+    UniValue obj(UniValue::VOBJ);
+    bool enabled = IsThinBlocksEnabled();
+    obj.push_back(Pair("enabled", enabled));
+    if (enabled) {
+        obj.push_back(Pair("summary", CThinBlockStats::ToString()));
+    }
+    return obj;
+}
+// BitcoinUnlimited BUIP010 : End
+
+
 UniValue getnetworkinfo(const UniValue& params, bool fHelp)
 {
     if (fHelp || params.size() != 0)
@@ -445,6 +461,7 @@
             "  ,...\n"
             "  ]\n"
             "  \"warnings\": \"...\"                    (string) any network warnings (such as alert messages) \n"
+            "  \"thinblockstats\": \"...\"              (string) thin block related statistics \n" 
             "}\n"
             "\nExamples:\n"
             + HelpExampleCli("getnetworkinfo", "")
@@ -475,6 +492,9 @@
         }
     }
     obj.push_back(Pair("localaddresses", localAddresses));
+// BitcoinUnlimited BUIP010: Start
+    obj.push_back(Pair("thinblockstats", GetThinBlockStats()));
+// BitcoinUnlimited BUIP010: End
     obj.push_back(Pair("warnings",       GetWarnings("statusbar")));
     return obj;
 }