From 5d6cf050a8bc853752b54b78bd717a5152b4f787 Mon Sep 17 00:00:00 2001 From: Inso <insomniak.fr@gmail.com> Date: Sat, 12 Sep 2015 21:58:43 +0200 Subject: [PATCH] Multiple small fixes --- src/cutecoin/core/net/node.py | 11 +++++++---- src/cutecoin/core/txhistory.py | 7 ++++--- src/cutecoin/gui/community_view.py | 5 ++++- src/cutecoin/gui/mainwindow.py | 3 --- src/cutecoin/gui/transactions_tab.py | 1 - src/cutecoin/models/txhistory.py | 6 ++++-- 6 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/cutecoin/core/net/node.py b/src/cutecoin/core/net/node.py index 38aaf17d..794f40ff 100644 --- a/src/cutecoin/core/net/node.py +++ b/src/cutecoin/core/net/node.py @@ -460,10 +460,13 @@ class Node(QObject): if self.check_noerror(reply.error(), status_code): strdata = bytes(reply.readAll()).decode('utf-8') leaf_data = json.loads(strdata) - peer_doc = Peer.from_signed_raw("{0}{1}\n".format(leaf_data['leaf']['value']['raw'], - leaf_data['leaf']['value']['signature'])) - pubkey = leaf_data['leaf']['value']['pubkey'] - self.neighbour_found.emit(peer_doc, pubkey) + if "raw" in leaf_data['leaf']['value']: + peer_doc = Peer.from_signed_raw("{0}{1}\n".format(leaf_data['leaf']['value']['raw'], + leaf_data['leaf']['value']['signature'])) + pubkey = leaf_data['leaf']['value']['pubkey'] + self.neighbour_found.emit(peer_doc, pubkey) + else: + logging.debug("Incorrect leaf reply") else: logging.debug("Error in leaf reply") self.changed.emit() diff --git a/src/cutecoin/core/txhistory.py b/src/cutecoin/core/txhistory.py index 6105ac21..e959a3ec 100644 --- a/src/cutecoin/core/txhistory.py +++ b/src/cutecoin/core/txhistory.py @@ -225,7 +225,7 @@ class TxHistory(): # Lets look if transactions took too long to be validated awaiting = [t for t in self._transfers if t.state == Transfer.AWAITING] - while parsed_block < current_block['number']: + while parsed_block <= current_block['number']: udid = 0 for d in [ud for ud in dividends if ud['block_number'] == parsed_block]: state = yield from TxHistory._validation_state(community, d['block_number'], current_block) @@ -256,10 +256,11 @@ class TxHistory(): return self.latest_block = current_block['number'] + parameters = yield from community.parameters() for transfer in awaiting: transfer.check_refused(current_block['medianTime'], - community.parameters['avgGenTime'], - community.parameters['medianTimeBlocks']) + parameters['avgGenTime'], + parameters['medianTimeBlocks']) self._transfers = self._transfers + new_transfers self._dividends = self._dividends + new_dividends diff --git a/src/cutecoin/gui/community_view.py b/src/cutecoin/gui/community_view.py index 3cee3564..98aa8336 100644 --- a/src/cutecoin/gui/community_view.py +++ b/src/cutecoin/gui/community_view.py @@ -121,6 +121,7 @@ class CommunityWidget(QWidget, Ui_CommunityWidget): community.network.nodes_changed.connect(self.refresh_status) self.label_currency.setText(community.currency) self.community = community + self.refresh_status() self.refresh_quality_buttons() @pyqtSlot(str) @@ -211,7 +212,9 @@ class CommunityWidget(QWidget, Ui_CommunityWidget): label_text += " - {0}".format(status_infotext) if self.app.preferences['expert_mode']: - label_text += self.tr(" - Median fork window : {0}").format(self.community.network.fork_window(self.community.members_pubkeys())) + members_pubkeys = yield from self.community.members_pubkeys() + label_text += self.tr(" - Median fork window : {0}")\ + .format(self.community.network.fork_window(members_pubkeys)) self.status_label.setText(label_text) diff --git a/src/cutecoin/gui/mainwindow.py b/src/cutecoin/gui/mainwindow.py index 50b6b226..c59870d3 100644 --- a/src/cutecoin/gui/mainwindow.py +++ b/src/cutecoin/gui/mainwindow.py @@ -255,9 +255,6 @@ class MainWindow(QMainWindow, Ui_MainWindow): @pyqtSlot(Community) def change_community(self, community): - if self.community_view.community: - self.community_view.community.stop_coroutines() - if community: self.homescreen.hide() self.community_view.show() diff --git a/src/cutecoin/gui/transactions_tab.py b/src/cutecoin/gui/transactions_tab.py index f452b669..d2f2e715 100644 --- a/src/cutecoin/gui/transactions_tab.py +++ b/src/cutecoin/gui/transactions_tab.py @@ -96,7 +96,6 @@ class TransactionsTabWidget(QWidget, Ui_transactionsTabWidget): #TODO: Use resetmodel instead of destroy/create if self.community: self.refresh_minimum_maximum() - self.refresh_balance() def start_progress(self): diff --git a/src/cutecoin/models/txhistory.py b/src/cutecoin/models/txhistory.py index bd22eccb..31cdc1d3 100644 --- a/src/cutecoin/models/txhistory.py +++ b/src/cutecoin/models/txhistory.py @@ -18,7 +18,6 @@ from PyQt5.QtGui import QFont, QColor class TxFilterProxyModel(QSortFilterProxyModel): def __init__(self, ts_from, ts_to, parent=None): super().__init__(parent) - self.community = None self.app = None self.ts_from = ts_from self.ts_to = ts_to @@ -67,11 +66,14 @@ class TxFilterProxyModel(QSortFilterProxyModel): return in_period(date) + @property + def community(self): + return self.sourceModel().community + def columnCount(self, parent): return self.sourceModel().columnCount(None) - 5 def setSourceModel(self, sourceModel): - self.community = sourceModel.community self.app = sourceModel.app super().setSourceModel(sourceModel) -- GitLab