From 6679eea04c36464e46c7c123af74b5461eea7bc4 Mon Sep 17 00:00:00 2001 From: Neil Booth Date: Sun, 18 Dec 2016 07:57:48 +0900 Subject: [PATCH 1/4] getinfo RPC: change height reporting Also rename watched to subs Closes #80 --- server/protocol.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server/protocol.py b/server/protocol.py index 1b06a77..1908812 100644 --- a/server/protocol.py +++ b/server/protocol.py @@ -408,7 +408,8 @@ class ServerManager(util.LoggedClass): def server_summary(self): '''A one-line summary of server state.''' return { - 'blocks': self.bp.db_height, + 'daemon_height': self.bp.daemon.cached_height(), + 'db_height': self.bp.db_height, 'closing': len([s for s in self.sessions if s.is_closing()]), 'errors': sum(s.error_count for s in self.sessions), 'groups': len(self.groups), @@ -416,8 +417,8 @@ class ServerManager(util.LoggedClass): 'peers': len(self.irc.peers), 'requests': sum(s.requests_remaining() for s in self.sessions), 'sessions': self.session_count(), + 'subs': self.subscription_count, 'txs_sent': self.txs_sent, - 'watched': self.subscription_count, } @staticmethod From 378372e666fb211e50ff30d570fc0f56cf288d16 Mon Sep 17 00:00:00 2001 From: Neil Booth Date: Sun, 18 Dec 2016 08:06:56 +0900 Subject: [PATCH 2/4] Logs: show IPv6 address + port correctly Closes #79 --- lib/jsonrpc.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/jsonrpc.py b/lib/jsonrpc.py index c13cc15..9a74eaa 100644 --- a/lib/jsonrpc.py +++ b/lib/jsonrpc.py @@ -177,7 +177,10 @@ class JSONRPC(asyncio.Protocol, LoggedClass): return 'unknown' if for_log and self.anon_logs: return 'xx.xx.xx.xx:xx' - return '{}:{}'.format(self.peer_info[0], self.peer_info[1]) + if ':' in self.peer_info[0]: + return '[{}]:{}'.format(self.peer_info[0], self.peer_info[1]) + else: + return '{}:{}'.format(self.peer_info[0], self.peer_info[1]) def connection_made(self, transport): '''Handle an incoming client connection.''' From 3cf23c88bdcbd01c8a28d99e61c30eb050d77501 Mon Sep 17 00:00:00 2001 From: Neil Booth Date: Sun, 18 Dec 2016 08:10:20 +0900 Subject: [PATCH 3/4] Start up RPC server immediately Don't wait for catch-up Closes #78 --- server/protocol.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/server/protocol.py b/server/protocol.py index 1908812..ecf9828 100644 --- a/server/protocol.py +++ b/server/protocol.py @@ -224,10 +224,9 @@ class ServerManager(util.LoggedClass): async def start_servers(self, caught_up): '''Start RPC, TCP and SSL servers once caught up.''' - await caught_up.wait() - if self.env.rpc_port is not None: await self.start_server('RPC', 'localhost', self.env.rpc_port) + await caught_up.wait() await self.start_external_servers() async def start_external_servers(self): From 0dccb795dce4742d96e9caeef5327d6ca20303af Mon Sep 17 00:00:00 2001 From: Neil Booth Date: Sun, 18 Dec 2016 08:13:17 +0900 Subject: [PATCH 4/4] Add pid to RPC getinfo Closes #77 --- server/protocol.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server/protocol.py b/server/protocol.py index ecf9828..5e343cb 100644 --- a/server/protocol.py +++ b/server/protocol.py @@ -11,6 +11,7 @@ import asyncio import codecs import json +import os import ssl import time import traceback @@ -413,6 +414,7 @@ class ServerManager(util.LoggedClass): 'errors': sum(s.error_count for s in self.sessions), 'groups': len(self.groups), 'logged': len([s for s in self.sessions if s.log_me]), + 'pid': os.getpid(), 'peers': len(self.irc.peers), 'requests': sum(s.requests_remaining() for s in self.sessions), 'sessions': self.session_count(),