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

Display dividends in darkblue

parent 5d509f7e
No related branches found
No related tags found
No related merge requests found
...@@ -43,6 +43,7 @@ class DividendsProcessor: ...@@ -43,6 +43,7 @@ class DividendsProcessor:
history_data = await self._bma_connector.get(identity.currency, bma.ud.history, history_data = await self._bma_connector.get(identity.currency, bma.ud.history,
req_args={'pubkey': identity.pubkey}) req_args={'pubkey': identity.pubkey})
log_stream("Found {0} available dividends".format(len(history_data["history"]["history"]))) log_stream("Found {0} available dividends".format(len(history_data["history"]["history"])))
block_numbers = []
for ud_data in history_data["history"]["history"]: for ud_data in history_data["history"]["history"]:
dividend = Dividend(currency=identity.currency, dividend = Dividend(currency=identity.currency,
pubkey=identity.pubkey, pubkey=identity.pubkey,
...@@ -51,6 +52,7 @@ class DividendsProcessor: ...@@ -51,6 +52,7 @@ class DividendsProcessor:
amount=ud_data["amount"], amount=ud_data["amount"],
base=ud_data["base"]) base=ud_data["base"])
log_stream("Dividend of block {0}".format(dividend.block_number)) log_stream("Dividend of block {0}".format(dividend.block_number))
block_numbers.append(dividend.block_number)
try: try:
self._repo.insert(dividend) self._repo.insert(dividend)
except sqlite3.IntegrityError: except sqlite3.IntegrityError:
...@@ -59,11 +61,10 @@ class DividendsProcessor: ...@@ -59,11 +61,10 @@ class DividendsProcessor:
for tx in transactions: for tx in transactions:
txdoc = Transaction.from_signed_raw(tx.raw) txdoc = Transaction.from_signed_raw(tx.raw)
for input in txdoc.inputs: for input in txdoc.inputs:
if input.source == "D": if input.source == "D" and input.index not in block_numbers:
block = await self._bma_connector.get(identity.currency, block = await self._bma_connector.get(identity.currency,
bma.blockchain.block, req_args={'number': input.index}) bma.blockchain.block, req_args={'number': input.index})
if input.amount == 0:
pass
dividend = Dividend(currency=identity.currency, dividend = Dividend(currency=identity.currency,
pubkey=identity.pubkey, pubkey=identity.pubkey,
block_number=input.index, block_number=input.index,
......
...@@ -141,6 +141,8 @@ class TxFilterProxyModel(QSortFilterProxyModel): ...@@ -141,6 +141,8 @@ class TxFilterProxyModel(QSortFilterProxyModel):
if source_index.column() == model.columns_types.index('amount'): if source_index.column() == model.columns_types.index('amount'):
if source_data < 0: if source_data < 0:
return QColor(Qt.darkRed) return QColor(Qt.darkRed)
elif state_data == HistoryTableModel.DIVIDEND:
return QColor(Qt.darkBlue)
if role == Qt.TextAlignmentRole: if role == Qt.TextAlignmentRole:
if self.sourceModel().columns_types.index('amount'): if self.sourceModel().columns_types.index('amount'):
...@@ -171,6 +173,8 @@ class HistoryTableModel(QAbstractTableModel): ...@@ -171,6 +173,8 @@ class HistoryTableModel(QAbstractTableModel):
A Qt abstract item model to display communities in a tree A Qt abstract item model to display communities in a tree
""" """
DIVIDEND = 32
def __init__(self, parent, app, connection, identities_service, transactions_service): def __init__(self, parent, app, connection, identities_service, transactions_service):
""" """
History of all transactions History of all transactions
...@@ -299,7 +303,7 @@ class HistoryTableModel(QAbstractTableModel): ...@@ -299,7 +303,7 @@ class HistoryTableModel(QAbstractTableModel):
receiver = dividend.pubkey receiver = dividend.pubkey
date_ts = dividend.timestamp date_ts = dividend.timestamp
return (date_ts, receiver, amount, "", Transaction.VALIDATED, 0, return (date_ts, receiver, amount, "", HistoryTableModel.DIVIDEND, 0,
receiver, block_number, "") receiver, block_number, "")
def init_transfers(self): def init_transfers(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment