From c998583ec075ad9af91cc5b3a02f8808c6366840 Mon Sep 17 00:00:00 2001 From: Inso <insomniak.fr@gmail.com> Date: Tue, 30 Jun 2015 20:43:02 +0200 Subject: [PATCH] Correction de bug lors du rafraichissement des tx --- src/cutecoin/core/account.py | 2 +- src/cutecoin/core/txhistory.py | 15 +++++++-------- src/cutecoin/gui/transactions_tab.py | 9 ++++++--- src/cutecoin/models/txhistory.py | 4 ++-- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/cutecoin/core/account.py b/src/cutecoin/core/account.py index cd4151d4..fe2e4c0d 100644 --- a/src/cutecoin/core/account.py +++ b/src/cutecoin/core/account.py @@ -259,7 +259,7 @@ class Account(QObject): def progressing(value, maximum, hash): logging.debug("Loading = {0} : {1} : {2}".format(value, maximum, loaded_wallets)) values[hash] = value - maximums[maximum] = maximum + maximums[hash] = maximum account_value = sum(values.values()) account_max = sum(maximums.values()) self.loading_progressed.emit(account_value, account_max) diff --git a/src/cutecoin/core/txhistory.py b/src/cutecoin/core/txhistory.py index b54ed4f3..3f8fae1a 100644 --- a/src/cutecoin/core/txhistory.py +++ b/src/cutecoin/core/txhistory.py @@ -59,10 +59,7 @@ class TxHistory(): self._stop_coroutines = True @asyncio.coroutine - def _parse_transaction(self, community, txdata, new_transfers, received_list, txid): - if len(txdata['issuers']) == 0: - return True - + def _parse_transaction(self, community, txdata, received_list, txid): tx_outputs = [OutputSource.from_inline(o) for o in txdata['outputs']] receivers = [o.pubkey for o in tx_outputs if o.pubkey != txdata['issuers'][0]] @@ -115,7 +112,7 @@ class TxHistory(): if txdata['hash'] not in [t['hash'] for t in awaiting]: transfer = Transfer.create_validated(txdata['hash'], metadata.copy()) - new_transfers.append(transfer) + return transfer # If we are not in the issuers, # maybe it we are in the recipients of this transaction elif in_outputs: @@ -127,8 +124,8 @@ class TxHistory(): metadata['amount'] = amount received = Received(txdata['hash'], metadata.copy()) received_list.append(received) - new_transfers.append(received) - return True + return received + return None @asyncio.coroutine def refresh(self, community, received_list): @@ -166,7 +163,9 @@ class TxHistory(): parsed_block, current_block)) else: - yield from self._parse_transaction(community, txdata, new_transfers, received_list, txid) + transfer = yield from self._parse_transaction(community, txdata, received_list, txid) + if transfer: + new_transfers.append(transfer) self.wallet.refresh_progressed.emit(parsed_block, current_block, self.wallet.pubkey) parsed_block += 100 diff --git a/src/cutecoin/gui/transactions_tab.py b/src/cutecoin/gui/transactions_tab.py index 1e5a4579..5191a5c6 100644 --- a/src/cutecoin/gui/transactions_tab.py +++ b/src/cutecoin/gui/transactions_tab.py @@ -35,13 +35,14 @@ class TransactionsTabWidget(QWidget, Ui_transactionsTabWidget): self.community = community self.password_asker = password_asker self.currency_tab = currency_tab - self.app.current_account.loading_finished.connect(self.stop_progress) self.progressbar.hide() + self.community.inner_data_changed.connect(self.refresh_minimum_maximum) self.refresh() - def refresh(self): + def refresh_minimum_maximum(self): + block = self.community.get_block(1) minimum_datetime = QDateTime() - minimum_datetime.setTime_t(self.community.get_block(1)['medianTime']) + minimum_datetime.setTime_t(block['medianTime']) minimum_datetime.setTime(QTime(0, 0)) self.date_from.setMinimumDateTime(minimum_datetime) @@ -53,6 +54,8 @@ class TransactionsTabWidget(QWidget, Ui_transactionsTabWidget): self.date_to.setDateTime(tomorrow_datetime) self.date_to.setMaximumDateTime(tomorrow_datetime) + def refresh(self): + self.refresh_minimum_maximum() ts_from = self.date_from.dateTime().toTime_t() ts_to = self.date_to.dateTime().toTime_t() diff --git a/src/cutecoin/models/txhistory.py b/src/cutecoin/models/txhistory.py index c34c231f..e82f44c9 100644 --- a/src/cutecoin/models/txhistory.py +++ b/src/cutecoin/models/txhistory.py @@ -236,7 +236,7 @@ class HistoryTableModel(QAbstractTableModel): self.endResetModel() def rowCount(self, parent): - return len(self.transfers) + return len(self.transfers_data) def columnCount(self, parent): return len(self.columns_types) @@ -262,7 +262,7 @@ class HistoryTableModel(QAbstractTableModel): return self.transfers_data[row][col] if role == Qt.ToolTipRole and col == 0: - return self.transfers[row].metadata['time'] + return self.transfers_data[self.columns_types.index('date')] def flags(self, index): return Qt.ItemIsSelectable | Qt.ItemIsEnabled -- GitLab