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

Fix some bugs in transactions parsing

parent 40c15fb4
Branches
Tags
No related merge requests found
...@@ -18,12 +18,27 @@ from PyQt5.QtCore import QObject, pyqtSignal ...@@ -18,12 +18,27 @@ from PyQt5.QtCore import QObject, pyqtSignal
class LocalState(Enum): 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 NOT_FOUND = 0
PARTIAL = 1 PARTIAL = 1
COMPLETED = 2 COMPLETED = 2
class BlockchainState(Enum): 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 NOT_FOUND = 0
BUFFERED = 1 BUFFERED = 1
VALIDATED = 2 VALIDATED = 2
......
...@@ -117,7 +117,7 @@ class Transfer(QObject): ...@@ -117,7 +117,7 @@ class Transfer(QObject):
blockid = yield from community.blockid() blockid = yield from community.blockid()
block = yield from community.bma_access.future_request(qtbma.blockchain.Block, block = yield from community.bma_access.future_request(qtbma.blockchain.Block,
req_args={'number': blockid['number']}) 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['block'] = blockid['number']
self._metadata['time'] = block['medianTime'] self._metadata['time'] = block['medianTime']
......
...@@ -77,7 +77,7 @@ class TxHistory(): ...@@ -77,7 +77,7 @@ class TxHistory():
if o.pubkey != txdata['issuers'][0]] if o.pubkey != txdata['issuers'][0]]
block_number = txdata['block_number'] 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 state = Transfer.VALIDATED
else: else:
state = Transfer.VALIDATING state = Transfer.VALIDATING
...@@ -118,7 +118,7 @@ class TxHistory(): ...@@ -118,7 +118,7 @@ class TxHistory():
# We check if the transaction correspond to one we sent # We check if the transaction correspond to one we sent
# but not from this cutecoin Instance # 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 the wallet pubkey is in the issuers we sent this transaction
if in_issuers: if in_issuers:
outputs = [o for o in tx_outputs outputs = [o for o in tx_outputs
...@@ -141,14 +141,14 @@ class TxHistory(): ...@@ -141,14 +141,14 @@ class TxHistory():
amount += o.amount amount += o.amount
metadata['amount'] = 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'], transfer = Transfer.create_from_blockchain(txdata['hash'],
state, state,
metadata.copy()) metadata.copy())
received_list.append(transfer) received_list.append(transfer)
return transfer return transfer
else: 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, transfer.check_registered(txdata['hash'], current_block, mediantime,
self.app.preferences['data_validation']) self.app.preferences['data_validation'])
return None return None
...@@ -208,7 +208,8 @@ class TxHistory(): ...@@ -208,7 +208,8 @@ class TxHistory():
parsed_block, parsed_block,
current_block['number'])) current_block['number']))
else: 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: if transfer:
new_transfers.append(transfer) new_transfers.append(transfer)
......
...@@ -79,11 +79,11 @@ class IdentitiesTableModel(QAbstractTableModel): ...@@ -79,11 +79,11 @@ class IdentitiesTableModel(QAbstractTableModel):
""" """
super().__init__(parent) super().__init__(parent)
self.community = community self.community = community
self.columns_titles = { self.columns_titles = {'uid': self.tr('UID'),
'uid': self.tr('UID'),
'pubkey': self.tr('Pubkey'), 'pubkey': self.tr('Pubkey'),
'renewed': self.tr('Renewed'), 'renewed': self.tr('Renewed'),
'expiration': self.tr('Expiration')} 'expiration': self.tr('Expiration'),
'validation': self.tr('Validation')}
self.columns_ids = ('uid', 'pubkey', 'renewed', 'expiration') self.columns_ids = ('uid', 'pubkey', 'renewed', 'expiration')
self.identities_data = [] self.identities_data = []
self._identities = [] self._identities = []
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment