Skip to content
Snippets Groups Projects
Commit eeb0f8a3 authored by inso's avatar inso
Browse files

Fix wrong network behaviour when root nodes change identity

parent 9450780a
No related branches found
No related tags found
No related merge requests found
...@@ -72,15 +72,15 @@ class Application(QObject): ...@@ -72,15 +72,15 @@ class Application(QObject):
} }
self.notifications = {'membership_expire_soon': self.notifications = {'membership_expire_soon':
( [
self.tr("Warning : Your membership is expiring soon."), self.tr("Warning : Your membership is expiring soon."),
0 0
), ],
'warning_certifications': 'warning_certifications':
( [
self.tr("Warning : Your could miss certifications soon."), self.tr("Warning : Your could miss certifications soon."),
0 0
) ]
} }
@classmethod @classmethod
......
...@@ -98,7 +98,6 @@ class Network(QObject): ...@@ -98,7 +98,6 @@ class Network(QObject):
node = Node.from_json(currency, data) node = Node.from_json(currency, data)
nodes.append(node) nodes.append(node)
network = cls(currency, nodes) network = cls(currency, nodes)
# We block the signals until loading the nodes cache
return network return network
def jsonify(self): def jsonify(self):
...@@ -269,6 +268,7 @@ class Network(QObject): ...@@ -269,6 +268,7 @@ class Network(QObject):
""" """
self._nodes.append(node) self._nodes.append(node)
node.changed.connect(self.handle_change) node.changed.connect(self.handle_change)
node.identity_changed.connect(self.handle_identity_change)
node.neighbour_found.connect(self.handle_new_node) node.neighbour_found.connect(self.handle_new_node)
logging.debug("{:} connected".format(node.pubkey[:5])) logging.debug("{:} connected".format(node.pubkey[:5]))
...@@ -330,6 +330,13 @@ class Network(QObject): ...@@ -330,6 +330,13 @@ class Network(QObject):
except InvalidNodeCurrency as e: except InvalidNodeCurrency as e:
logging.debug(str(e)) logging.debug(str(e))
@pyqtSlot()
def handle_identity_change(self):
node = self.sender()
if node in self._root_nodes:
self.root_nodes_changed.emit()
self.nodes_changed.emit()
@pyqtSlot() @pyqtSlot()
def handle_change(self): def handle_change(self):
node = self.sender() node = self.sender()
......
...@@ -36,6 +36,7 @@ class Node(QObject): ...@@ -36,6 +36,7 @@ class Node(QObject):
CORRUPTED = 4 CORRUPTED = 4
changed = pyqtSignal() changed = pyqtSignal()
identity_changed = pyqtSignal()
neighbour_found = pyqtSignal(Peer, str) neighbour_found = pyqtSignal(Peer, str)
def __init__(self, currency, endpoints, uid, pubkey, block, def __init__(self, currency, endpoints, uid, pubkey, block,
...@@ -345,18 +346,15 @@ class Node(QObject): ...@@ -345,18 +346,15 @@ class Node(QObject):
node_currency = peering_data["currency"] node_currency = peering_data["currency"]
self.state = Node.ONLINE self.state = Node.ONLINE
change = False
if node_pubkey != self.pubkey: if node_pubkey != self.pubkey:
self._pubkey = node_pubkey self._pubkey = node_pubkey
change = True self.identity_changed.emit()
if node_currency != self.currency: if node_currency != self.currency:
self.state = Node.CORRUPTED self.state = Node.CORRUPTED
logging.debug("Change : new state corrupted") logging.debug("Change : new state corrupted")
change = True
if change:
self.changed.emit() self.changed.emit()
except ValueError as e: except ValueError as e:
logging.debug("Error in peering reply : {0}".format(str(e))) logging.debug("Error in peering reply : {0}".format(str(e)))
self.changed.emit() self.changed.emit()
...@@ -415,13 +413,13 @@ class Node(QObject): ...@@ -415,13 +413,13 @@ class Node(QObject):
uid = uid["uid"] uid = uid["uid"]
if self._uid != uid: if self._uid != uid:
self._uid = uid self._uid = uid
self.changed.emit() self.identity_changed.emit()
except ValueError as e: except ValueError as e:
if '404' in str(e): if '404' in str(e):
logging.debug("UID not found") logging.debug("UID not found")
else: else:
logging.debug("error in uid reply") logging.debug("error in uid reply")
self.changed.emit() self.identity_changed.emit()
except ClientError: except ClientError:
logging.debug("Client error : {0}".format(self.pubkey)) logging.debug("Client error : {0}".format(self.pubkey))
self.state = Node.OFFLINE self.state = Node.OFFLINE
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment