From 5b5ec2b63d5a9edb93b041ce665b5db883fbdb52 Mon Sep 17 00:00:00 2001 From: Dmitri Bogomolov <4glitch@gmail.com> Date: Thu, 1 Nov 2018 16:28:42 +0200 Subject: [PATCH] shared.connectedHostsList is obsolete --- src/bitmessagecurses/__init__.py | 12 +++++++++--- src/network/bmproto.py | 1 - src/shared.py | 5 +---- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/bitmessagecurses/__init__.py b/src/bitmessagecurses/__init__.py index fe9a77d2..dc6e8a0c 100644 --- a/src/bitmessagecurses/__init__.py +++ b/src/bitmessagecurses/__init__.py @@ -31,6 +31,8 @@ from pyelliptic.openssl import OpenSSL import queues import shared import shutdown +import network.stats + quit = False menutab = 1 @@ -209,12 +211,16 @@ def drawtab(stdscr): stdscr.addstr(6+i, 120, str(item[2]), a) elif menutab == 8: # Network status # Connection data - stdscr.addstr(4, 5, "Total Connections: "+str(len(shared.connectedHostsList)).ljust(2)) + connected_hosts = network.stats.connectedHostsList() + stdscr.addstr( + 4, 5, "Total Connections: " + + str(len(connected_hosts)).ljust(2) + ) stdscr.addstr(6, 6, "Stream #", curses.A_BOLD) stdscr.addstr(6, 18, "Connections", curses.A_BOLD) stdscr.hline(7, 6, '-', 23) streamcount = [] - for host, stream in shared.connectedHostsList.items(): + for host, stream in connected_hosts: if stream >= len(streamcount): streamcount.append(1) else: @@ -776,7 +782,7 @@ def sendMessage(sender="", recv="", broadcast=None, subject="", body="", reply=F set_background_title(d, "Recipient address error") scrollbox(d, unicode("Bitmessage currently only supports stream numbers of 1, unlike as requested for address " + addr + ".")) continue - if len(shared.connectedHostsList) == 0: + if not network.stats.connectedHostsList(): set_background_title(d, "Not connected warning") scrollbox(d, unicode("Because you are not currently connected to the network, ")) stealthLevel = BMConfigParser().safeGetInt('bitmessagesettings', 'ackstealthlevel') diff --git a/src/network/bmproto.py b/src/network/bmproto.py index bdebe0fb..26ab8908 100644 --- a/src/network/bmproto.py +++ b/src/network/bmproto.py @@ -431,7 +431,6 @@ class BMProto(AdvancedDispatcher, ObjectTracker): if not self.peerValidityChecks(): # TODO ABORT return True - #shared.connectedHostsList[self.destination] = self.streams[0] self.append_write_buf(protocol.CreatePacket('verack')) self.verackSent = True if not self.isOutbound: diff --git a/src/shared.py b/src/shared.py index 76769a02..6a2980d9 100644 --- a/src/shared.py +++ b/src/shared.py @@ -50,10 +50,7 @@ myAddressesByTag = {} broadcastSendersForWhichImWatching = {} printLock = threading.Lock() statusIconColor = 'red' -# List of hosts to which we are connected. Used to guarantee -# that the outgoingSynSender threads won't connect to the same -# remote node twice. -connectedHostsList = {} + thisapp = None # singleton lock instance alreadyAttemptedConnectionsList = { } # This is a list of nodes to which we have already attempted a connection