Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
yungwine committed Jan 28, 2024
2 parents 02dbffa + ba773c0 commit f29ba96
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
3 changes: 2 additions & 1 deletion pytoniq/liteclient/balancer.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,8 @@ async def raw_get_transactions(self, address: typing.Union[Address, str], count:
return await self.execute_method('raw_get_transactions', **self._get_args(locals()))

async def get_transactions(self, address: typing.Union[Address, str], count: int,
from_lt: int = None, from_hash: typing.Optional[bytes] = None
from_lt: int = None, from_hash: typing.Optional[bytes] = None,
to_lt: int = 0
, **kwargs) -> typing.List[Transaction]:
return await self.execute_method('get_transactions', **self._get_args(locals()))

Expand Down
15 changes: 13 additions & 2 deletions pytoniq/liteclient/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,21 +646,32 @@ async def raw_get_transactions(self, address: typing.Union[Address, str], count:
return tr_result, block_ids

async def get_transactions(self, address: typing.Union[Address, str], count: int,
from_lt: int = None, from_hash: typing.Optional[bytes] = None
from_lt: int = None, from_hash: typing.Optional[bytes] = None,
to_lt: int = 0
) -> typing.List[Transaction]:
"""
Returns account transactions
:param address:
:param count:
:param from_lt:
:param from_hash:
:param to_lt:
:return:
"""
result: typing.List[Transaction] = []
reach_lt = False

for i in range(0, count, 16):
amount = min(16, count - i)
tr_result, block_ids = await self.raw_get_transactions(address, amount, from_lt, from_hash)
tr_result, _ = await self.raw_get_transactions(address, amount, from_lt, from_hash)
if to_lt > 0 and tr_result[-1].lt <= to_lt:
for j, t in enumerate(tr_result):
if t.lt <= to_lt:
result += tr_result[:j]
reach_lt = True
break
if reach_lt:
break
result += tr_result
from_lt, from_hash = result[-1].prev_trans_lt, result[-1].prev_trans_hash
if from_lt == 0:
Expand Down

0 comments on commit f29ba96

Please sign in to comment.