From a7fc1f55aebcad7932a219ed5ad616440770c6b5 Mon Sep 17 00:00:00 2001 From: Inso <insomniak.fr@gmail.com> Date: Fri, 21 Aug 2015 14:06:32 +0200 Subject: [PATCH] Fix some bugs in transactions parsing --- src/cutecoin/core/registry/identity.py | 15 +++++++++++++++ src/cutecoin/core/transfer.py | 2 +- src/cutecoin/core/txhistory.py | 11 ++++++----- src/cutecoin/models/identities.py | 6 +++--- 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/cutecoin/core/registry/identity.py b/src/cutecoin/core/registry/identity.py index 03d073dd..30ab91f1 100644 --- a/src/cutecoin/core/registry/identity.py +++ b/src/cutecoin/core/registry/identity.py @@ -18,12 +18,27 @@ from PyQt5.QtCore import QObject, pyqtSignal class LocalState(Enum): + """ + The local state describes how the identity exists locally : + COMPLETED means all its related datas (certifiers, certified...) + were succefully downloaded + PARTIAL means not all data are present locally + NOT_FOUND means it could not be found anywhere + """ NOT_FOUND = 0 PARTIAL = 1 COMPLETED = 2 class BlockchainState(Enum): + """ + The blockchain state describes how the identity + was found : + VALIDATED means it was found in the blockchain + BUFFERED means it was found via a lookup but not in the + blockchain + NOT_FOUND means it could not be found anywhere + """ NOT_FOUND = 0 BUFFERED = 1 VALIDATED = 2 diff --git a/src/cutecoin/core/transfer.py b/src/cutecoin/core/transfer.py index b0807af1..e7ec9506 100644 --- a/src/cutecoin/core/transfer.py +++ b/src/cutecoin/core/transfer.py @@ -117,7 +117,7 @@ class Transfer(QObject): blockid = yield from community.blockid() block = yield from community.bma_access.future_request(qtbma.blockchain.Block, req_args={'number': blockid['number']}) - if block != qtbma.Blockchain.Block.null_value: + if block != qtbma.blockchain.Block.null_value: self._metadata['block'] = blockid['number'] self._metadata['time'] = block['medianTime'] diff --git a/src/cutecoin/core/txhistory.py b/src/cutecoin/core/txhistory.py index dfab7c97..8c60a80b 100644 --- a/src/cutecoin/core/txhistory.py +++ b/src/cutecoin/core/txhistory.py @@ -77,7 +77,7 @@ class TxHistory(): if o.pubkey != txdata['issuers'][0]] block_number = txdata['block_number'] - if block_number + self.app.preferences['data_validation'] >= current_block: + if block_number + self.app.preferences['data_validation'] >= current_block["number"]: state = Transfer.VALIDATED else: state = Transfer.VALIDATING @@ -118,7 +118,7 @@ class TxHistory(): # We check if the transaction correspond to one we sent # but not from this cutecoin Instance - if txdata['hash'] not in [t.metadata['hash'] for t in awaiting]: + if txdata['hash'] not in [t.hash for t in awaiting]: # If the wallet pubkey is in the issuers we sent this transaction if in_issuers: outputs = [o for o in tx_outputs @@ -141,14 +141,14 @@ class TxHistory(): amount += o.amount metadata['amount'] = amount - if txdata['hash'] not in [t['hash'] for t in awaiting]: + if txdata['hash'] not in [t.hash for t in awaiting]: transfer = Transfer.create_from_blockchain(txdata['hash'], state, metadata.copy()) received_list.append(transfer) return transfer else: - transfer = [t for t in awaiting if t.metadata['hash'] == txdata['hash']][0] + transfer = [t for t in awaiting if t.hash == txdata['hash']][0] transfer.check_registered(txdata['hash'], current_block, mediantime, self.app.preferences['data_validation']) return None @@ -208,7 +208,8 @@ class TxHistory(): parsed_block, current_block['number'])) else: - transfer = yield from self._parse_transaction(community, txdata, received_list, udid + txid) + transfer = yield from self._parse_transaction(community, txdata, received_list, + udid + txid, current_block) if transfer: new_transfers.append(transfer) diff --git a/src/cutecoin/models/identities.py b/src/cutecoin/models/identities.py index 7e32c77c..1a66f0f9 100644 --- a/src/cutecoin/models/identities.py +++ b/src/cutecoin/models/identities.py @@ -79,11 +79,11 @@ class IdentitiesTableModel(QAbstractTableModel): """ super().__init__(parent) self.community = community - self.columns_titles = { - 'uid': self.tr('UID'), + self.columns_titles = {'uid': self.tr('UID'), 'pubkey': self.tr('Pubkey'), 'renewed': self.tr('Renewed'), - 'expiration': self.tr('Expiration')} + 'expiration': self.tr('Expiration'), + 'validation': self.tr('Validation')} self.columns_ids = ('uid', 'pubkey', 'renewed', 'expiration') self.identities_data = [] self._identities = [] -- GitLab