From 470c6f97a4f1105f297ebb9ac876d91df3af9035 Mon Sep 17 00:00:00 2001 From: Inso <insomniak.fr@gmail.com> Date: Tue, 3 Mar 2015 08:37:20 +0100 Subject: [PATCH] Bug fixes Fixed a bug in broadcast Fixed a bug in jsonification --- res/icons/AUTHORS | 1 + res/icons/icons.qrc | 1 + src/cutecoin/core/community.py | 4 ++-- src/cutecoin/core/net/network.py | 3 ++- src/cutecoin/core/net/node.py | 8 ++++++++ src/cutecoin/gui/currency_tab.py | 4 +++- 6 files changed, 17 insertions(+), 4 deletions(-) diff --git a/res/icons/AUTHORS b/res/icons/AUTHORS index 4d9fb14b..0a9bc15f 100644 --- a/res/icons/AUTHORS +++ b/res/icons/AUTHORS @@ -7,3 +7,4 @@ noun_22441_cc.svg : Created by Bruno Castro noun_29542_cc.svg : Created by Chris Kerr noun_43022_cc.svg : Created by Jon Prepeluh noun_63271_cc.svg : Created by Mark Shorter +noun_43022_cc.svg : Created by Piotrek Chuchla diff --git a/res/icons/icons.qrc b/res/icons/icons.qrc index a69d4de1..bf77a31e 100644 --- a/res/icons/icons.qrc +++ b/res/icons/icons.qrc @@ -1,5 +1,6 @@ <RCC> <qresource prefix="icons"> + <file alias="network_icon">noun_21549_cc.svg</file> <file alias="informations_icon">iconmonstr-info-2-icon.svg</file> <file alias="community_icon">noun_22441_cc.svg</file> <file alias="wot_icon">noun_2651_cc.svg</file> diff --git a/src/cutecoin/core/community.py b/src/cutecoin/core/community.py index 90eef4b0..018f65f1 100644 --- a/src/cutecoin/core/community.py +++ b/src/cutecoin/core/community.py @@ -273,12 +273,12 @@ class Community(object): if not ok: raise value_error - if tries == len(self.peers): + if tries == len(self.nodes): raise NoPeerAvailable(self.currency, len(nodes)) def jsonify(self): data = {'currency': self.currency, - 'peers': self.network.jsonify()} + 'peers': self._network.jsonify()} return data def get_parameters(self): diff --git a/src/cutecoin/core/net/network.py b/src/cutecoin/core/net/network.py index c4df2f9a..665fe9d6 100644 --- a/src/cutecoin/core/net/network.py +++ b/src/cutecoin/core/net/network.py @@ -39,6 +39,7 @@ class Network(QObject): for data in json_data: node = Node.from_json(currency, data) nodes.append(node) + logging.debug("Loading : {:}".format(data['pubkey'])) block_max = max([n.block for n in nodes]) for node in nodes: node.check_sync(currency, block_max) @@ -88,7 +89,7 @@ class Network(QObject): last_inlines = [n.endpoint.inline() for n in self._nodes] hash_new_nodes = hash(tuple(frozenset(sorted(new_inlines)))) - hash_last_nodes= hash(tuple(frozenset(sorted(last_inlines)))) + hash_last_nodes = hash(tuple(frozenset(sorted(last_inlines)))) if hash_new_nodes != hash_last_nodes: self._nodes = nodes diff --git a/src/cutecoin/core/net/node.py b/src/cutecoin/core/net/node.py index 3223fe03..448e14a8 100644 --- a/src/cutecoin/core/net/node.py +++ b/src/cutecoin/core/net/node.py @@ -52,6 +52,14 @@ class Node(QObject): node.refresh_state(currency) return node + def jsonify(self): + data = {'pubkey': self._pubkey} + endpoints = [] + for e in self._endpoints: + endpoints.append(e.inline()) + data['endpoints'] = endpoints + return data + @property def pubkey(self): return self._pubkey diff --git a/src/cutecoin/gui/currency_tab.py b/src/cutecoin/gui/currency_tab.py index 0c27e390..fc0da0cd 100644 --- a/src/cutecoin/gui/currency_tab.py +++ b/src/cutecoin/gui/currency_tab.py @@ -134,7 +134,9 @@ class CurrencyTabWidget(QWidget, Ui_CurrencyTabWidget): "Informations") self.tab_network = NetworkTabWidget(self.community) - self.tabs_account.addTab(self.tab_network, "Network") + self.tabs_account.addTab(self.tab_network, + QIcon(":/icons/network_icon"), + "Network") self.tab_informations.refresh() blockid = self.community.current_blockid() block_number = blockid['number'] -- GitLab