This repository was archived by the owner on Sep 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
get_account_transactions looping infinitely over the same transaction #29
Copy link
Copy link
Open
Description
Hi @tducret ,
First of all, thanks for the great library! :-)
I was using your library to load historical transactions from last 2 years, when I noticed that get_account_transactions is getting stuck in a specific case.
In my example:
- first run of the loop
- from 2019-03-01 to 2019-03-15, returned 47 transactions
- algorithm takes startedDate from the oldest transactions and sets it as a new to parameter
- second run of the loop
- from 2019-03-01 to 2019-03-01 09:29:38, returned 1 transaction - the same transaction which was present in first run
- algorithm takes startedDate from the oldest transactions - which is the same as before
- step Downloading Transactions #2 is repeated endlessly
I worked around it by manually subtracting 1 second from the timestamp, as below.
def get_account_transactions(self, from_date=None, to_date=None):
"""Get the account transactions."""
raw_transactions = []
params = {}
if to_date:
params['to'] = int(to_date.timestamp()) * 1000
if from_date:
params['from'] = int(from_date.timestamp()) * 1000
while True:
ret = self.client._get(_URL_GET_TRANSACTIONS_LAST, params=params)
ret_transactions = ret.json()
if not ret_transactions:
break
params['to'] = ret_transactions[-1]['startedDate']-1000 # fixed, because this loop was endlessly fetching the same transaction
raw_transactions.extend(ret_transactions)
return AccountTransactions(raw_transactions)
I'm not sure if it is possible to have more than one transaction with the same startedDate, but if yes, then this is not a proper solution.
Did you encounter case like that with your account?
Regards,
Metadata
Metadata
Assignees
Labels
No labels