Skip to content
Snippets Groups Projects
Commit 317b41e0 authored by Vincent Texier's avatar Vincent Texier
Browse files

[enh] source type "D" and "T" now as Source entity constants

parent 05ea62a8
Branches
Tags
1 merge request!778Release 0.51.0
...@@ -3,6 +3,10 @@ import attr ...@@ -3,6 +3,10 @@ import attr
@attr.s(hash=True) @attr.s(hash=True)
class Source: class Source:
TYPE_TRANSACTION = "T"
TYPE_DIVIDEND = "D"
currency = attr.ib(converter=str) currency = attr.ib(converter=str)
pubkey = attr.ib(converter=str) pubkey = attr.ib(converter=str)
identifier = attr.ib(converter=str) identifier = attr.ib(converter=str)
......
import attr import attr
import logging import logging
from ..entities import Dividend from ..entities import Dividend, Source
from .nodes import NodesProcessor from .nodes import NodesProcessor
from ..connectors import BmaConnector from ..connectors import BmaConnector
from duniterpy.api import bma from duniterpy.api import bma
...@@ -82,7 +82,7 @@ class DividendsProcessor: ...@@ -82,7 +82,7 @@ class DividendsProcessor:
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 ( if (
input.source == "D" input.source == Source.TYPE_DIVIDEND
and input.origin_id == connection.pubkey and input.origin_id == connection.pubkey
and input.index not in block_numbers and input.index not in block_numbers
and input.index > start and input.index > start
......
...@@ -473,7 +473,7 @@ class DocumentsService: ...@@ -473,7 +473,7 @@ class DocumentsService:
currency=currency, currency=currency,
pubkey=pubkey, pubkey=pubkey,
identifier=txdoc.sha_hash, identifier=txdoc.sha_hash,
type="T", type=Source.TYPE_TRANSACTION,
noffset=offset, noffset=offset,
amount=output.amount, amount=output.amount,
base=output.base, base=output.base,
......
...@@ -74,7 +74,7 @@ class SourcesServices(QObject): ...@@ -74,7 +74,7 @@ class SourcesServices(QObject):
currency=self.currency, currency=self.currency,
pubkey=pubkey, pubkey=pubkey,
identifier=txdoc.sha_hash, identifier=txdoc.sha_hash,
type="T", type=Source.TYPE_TRANSACTION,
noffset=offset, noffset=offset,
amount=output.amount, amount=output.amount,
base=output.base, base=output.base,
...@@ -117,7 +117,7 @@ class SourcesServices(QObject): ...@@ -117,7 +117,7 @@ class SourcesServices(QObject):
currency=self.currency, currency=self.currency,
pubkey=pubkey, pubkey=pubkey,
identifier=pubkey, identifier=pubkey,
type="D", type=Source.TYPE_DIVIDEND,
noffset=dividend.block_number, noffset=dividend.block_number,
amount=dividend.amount, amount=dividend.amount,
base=dividend.base, base=dividend.base,
...@@ -218,7 +218,7 @@ class SourcesServices(QObject): ...@@ -218,7 +218,7 @@ class SourcesServices(QObject):
currency=self.currency, currency=self.currency,
pubkey=pubkey, pubkey=pubkey,
identifier=txdoc.sha_hash, identifier=txdoc.sha_hash,
type="T", type=Source.TYPE_TRANSACTION,
noffset=offset, noffset=offset,
amount=output.amount, amount=output.amount,
base=output.base, base=output.base,
......
...@@ -8,7 +8,7 @@ from sakia.data.entities.transaction import ( ...@@ -8,7 +8,7 @@ from sakia.data.entities.transaction import (
) )
from duniterpy.documents import Transaction as TransactionDoc from duniterpy.documents import Transaction as TransactionDoc
from duniterpy.documents import SimpleTransaction, Block from duniterpy.documents import SimpleTransaction, Block
from sakia.data.entities import Dividend from sakia.data.entities import Dividend, Source
from duniterpy.api import bma from duniterpy.api import bma
import logging import logging
...@@ -179,7 +179,7 @@ class TransactionsService(QObject): ...@@ -179,7 +179,7 @@ class TransactionsService(QObject):
for input in txdoc.inputs: for input in txdoc.inputs:
# For each dividends inputs, if it is consumed (not present in ud history) # For each dividends inputs, if it is consumed (not present in ud history)
if ( if (
input.source == "D" input.source == Source.TYPE_DIVIDEND
and input.origin_id == connection.pubkey and input.origin_id == connection.pubkey
and input.index not in block_numbers and input.index not in block_numbers
): ):
...@@ -292,7 +292,7 @@ class TransactionsService(QObject): ...@@ -292,7 +292,7 @@ class TransactionsService(QObject):
for input in txdoc.inputs: for input in txdoc.inputs:
# For each dividends inputs, if it is consumed (not present in ud history) # For each dividends inputs, if it is consumed (not present in ud history)
if ( if (
input.source == "D" input.source == Source.TYPE_DIVIDEND
and input.origin_id == pubkey and input.origin_id == pubkey
and input.index not in block_numbers and input.index not in block_numbers
): ):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment