Skip to content
Snippets Groups Projects
Commit 891744e8 authored by Caner Candan's avatar Caner Candan
Browse files

* merke_easy_parser get optional begin and end argument in to slice requests *...

* merke_easy_parser get optional begin and end argument in to slice requests * used in tx.Sender and tx.Recipient request
parent 2ede0179
No related branches found
No related tags found
No related merge requests found
...@@ -177,9 +177,9 @@ class API: ...@@ -177,9 +177,9 @@ class API:
return response return response
def merkle_easy_parser(self, path): def merkle_easy_parser(self, path, begin=None, end=None):
root = self.requests_get(path, leaves='true').json() root = self.requests_get(path, leaves='true').json()
for leaf in root['leaves']: for leaf in root['leaves'][begin:end]:
yield self.requests_get(path, leaf=leaf).json()['leaf'] yield self.requests_get(path, leaf=leaf).json()['leaf']
from . import pks, ucg, hdc, wrappers from . import pks, ucg, hdc, wrappers
...@@ -71,34 +71,42 @@ class Last(Base): ...@@ -71,34 +71,42 @@ class Last(Base):
class Sender(Base): class Sender(Base):
"""GET all the transactions sent by this sender and stored by this node (should contain all transactions of the sender).""" """GET all the transactions sent by this sender and stored by this node (should contain all transactions of the sender)."""
def __init__(self, pgp_fingerprint): def __init__(self, pgp_fingerprint, begin=None, end=None):
""" """
Arguments: Arguments:
- `pgp_fingerprint`: PGP fingerprint of the key we want to see sent transactions. - `pgp_fingerprint`: PGP fingerprint of the key we want to see sent transactions.
- `begin`: integer value used by the merkle parser to know when to begin requesting.
- `end`: integer value used by the merkle parser to know when to end requesting.
""" """
super().__init__() super().__init__()
self.pgp_fingerprint = pgp_fingerprint self.pgp_fingerprint = pgp_fingerprint
self.begin = begin
self.end = end
def __get__(self, **kwargs): def __get__(self, **kwargs):
return self.merkle_easy_parser('/sender/%s' % self.pgp_fingerprint) return self.merkle_easy_parser('/sender/%s' % self.pgp_fingerprint, begin=self.begin, end=self.end)
class Recipient(Base): class Recipient(Base):
"""GET all the transactions received for this recipient stored by this node.""" """GET all the transactions received for this recipient stored by this node."""
def __init__(self, pgp_fingerprint): def __init__(self, pgp_fingerprint, begin=None, end=None):
""" """
Arguments: Arguments:
- `pgp_fingerprint`: PGP fingerprint of the key we want to see sent transactions. - `pgp_fingerprint`: PGP fingerprint of the key we want to see sent transactions.
- `begin`: integer value used by the merkle parser to know when to begin requesting.
- `end`: integer value used by the merkle parser to know when to end requesting.
""" """
super().__init__() super().__init__()
self.pgp_fingerprint = pgp_fingerprint self.pgp_fingerprint = pgp_fingerprint
self.begin = begin
self.end = end
def __get__(self, **kwargs): def __get__(self, **kwargs):
return self.merkle_easy_parser('/recipient/%s' % self.pgp_fingerprint) return self.merkle_easy_parser('/recipient/%s' % self.pgp_fingerprint, begin=self.begin, end=self.end)
class View(Base): class View(Base):
"""GET the transaction of given TRANSACTION_ID.""" """GET the transaction of given TRANSACTION_ID."""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment