Commit 317b41e0 authored by Vincent Texier's avatar Vincent Texier

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

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