diff --git a/__init__.py b/__init__.py index 62ea64ab7eb9621e6623d25cbfb44325ae526778..38a920998b23a4645a39eff0789e6bb6b8e88108 100644 --- a/__init__.py +++ b/__init__.py @@ -177,9 +177,9 @@ class API: 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() - for leaf in root['leaves']: + for leaf in root['leaves'][begin:end]: yield self.requests_get(path, leaf=leaf).json()['leaf'] from . import pks, ucg, hdc, wrappers diff --git a/hdc/transactions/__init__.py b/hdc/transactions/__init__.py index cc230c0ae2e9b60515223d9b468c9cd0b19d7abb..61b6bb61ce0d79816aecd0645d20e14802aded8e 100644 --- a/hdc/transactions/__init__.py +++ b/hdc/transactions/__init__.py @@ -71,34 +71,42 @@ class Last(Base): class Sender(Base): """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: - `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__() self.pgp_fingerprint = pgp_fingerprint + self.begin = begin + self.end = end 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): """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: - `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__() self.pgp_fingerprint = pgp_fingerprint + self.begin = begin + self.end = end 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): """GET the transaction of given TRANSACTION_ID."""