Skip to content

Commit 891744e

Browse files
author
Caner Candan
committed
* merke_easy_parser get optional begin and end argument in to slice requests * used in tx.Sender and tx.Recipient request
1 parent 2ede017 commit 891744e

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,9 @@ def requests_post(self, path, **kwargs):
177177

178178
return response
179179

180-
def merkle_easy_parser(self, path):
180+
def merkle_easy_parser(self, path, begin=None, end=None):
181181
root = self.requests_get(path, leaves='true').json()
182-
for leaf in root['leaves']:
182+
for leaf in root['leaves'][begin:end]:
183183
yield self.requests_get(path, leaf=leaf).json()['leaf']
184184

185185
from . import pks, ucg, hdc, wrappers

hdc/transactions/__init__.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,34 +71,42 @@ def __get__(self, **kwargs):
7171
class Sender(Base):
7272
"""GET all the transactions sent by this sender and stored by this node (should contain all transactions of the sender)."""
7373

74-
def __init__(self, pgp_fingerprint):
74+
def __init__(self, pgp_fingerprint, begin=None, end=None):
7575
"""
7676
Arguments:
7777
- `pgp_fingerprint`: PGP fingerprint of the key we want to see sent transactions.
78+
- `begin`: integer value used by the merkle parser to know when to begin requesting.
79+
- `end`: integer value used by the merkle parser to know when to end requesting.
7880
"""
7981

8082
super().__init__()
8183

8284
self.pgp_fingerprint = pgp_fingerprint
85+
self.begin = begin
86+
self.end = end
8387

8488
def __get__(self, **kwargs):
85-
return self.merkle_easy_parser('/sender/%s' % self.pgp_fingerprint)
89+
return self.merkle_easy_parser('/sender/%s' % self.pgp_fingerprint, begin=self.begin, end=self.end)
8690

8791
class Recipient(Base):
8892
"""GET all the transactions received for this recipient stored by this node."""
8993

90-
def __init__(self, pgp_fingerprint):
94+
def __init__(self, pgp_fingerprint, begin=None, end=None):
9195
"""
9296
Arguments:
9397
- `pgp_fingerprint`: PGP fingerprint of the key we want to see sent transactions.
98+
- `begin`: integer value used by the merkle parser to know when to begin requesting.
99+
- `end`: integer value used by the merkle parser to know when to end requesting.
94100
"""
95101

96102
super().__init__()
97103

98104
self.pgp_fingerprint = pgp_fingerprint
105+
self.begin = begin
106+
self.end = end
99107

100108
def __get__(self, **kwargs):
101-
return self.merkle_easy_parser('/recipient/%s' % self.pgp_fingerprint)
109+
return self.merkle_easy_parser('/recipient/%s' % self.pgp_fingerprint, begin=self.begin, end=self.end)
102110

103111
class View(Base):
104112
"""GET the transaction of given TRANSACTION_ID."""

0 commit comments

Comments
 (0)