This repository was archived by the owner on May 14, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
DP-370 Fix history #93
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -213,31 +213,33 @@ async def get_account_tx_history(self, address: str, amount: Optional[int] = 10, | |
|
|
||
| tx_list = [] | ||
|
|
||
| requested_amount = amount if amount < MAX_RECORDS_PER_REQUEST else MAX_RECORDS_PER_REQUEST | ||
|
|
||
| horizon_response = await self.horizon.account_transactions(address, | ||
| cursor=cursor, limit=requested_amount, | ||
| order='desc' if descending else 'asc') | ||
|
|
||
| for transaction in horizon_response['_embedded']['records']: | ||
| raw_tx = RawTransaction(transaction) | ||
| if simple: | ||
| try: | ||
| simple_tx = SimplifiedTransaction(raw_tx) | ||
| tx_list.append(simple_tx) | ||
| except KinErrors.CantSimplifyError: | ||
| pass | ||
| else: | ||
| tx_list.append(raw_tx) | ||
| last_cursor = transaction['paging_token'] | ||
|
|
||
| remaining_txs = amount - len(tx_list) | ||
| # if we got all the txs that we wanted, or there are no more txs | ||
| # TODO: paging does not work DP-370 | ||
| if remaining_txs <= 0 or len(horizon_response['_embedded']['records']) < amount: | ||
| return tx_list | ||
| # If there are anymore transactions, recursively get the next transaction page | ||
| return tx_list.extend(await self.get_account_tx_history(address, remaining_txs, descending, last_cursor, simple)) | ||
| while True: | ||
| requested_amount = min(amount, MAX_RECORDS_PER_REQUEST) | ||
|
|
||
| horizon_response = await self.horizon.account_transactions(address, | ||
| cursor=cursor, limit=requested_amount, | ||
| order='desc' if descending else 'asc') | ||
|
|
||
| current_loop_txs = [] | ||
| for transaction in horizon_response['_embedded']['records']: | ||
| raw_tx = RawTransaction(transaction) | ||
| if simple: | ||
| try: | ||
| simple_tx = SimplifiedTransaction(raw_tx) | ||
| current_loop_txs.append(simple_tx) | ||
| except KinErrors.CantSimplifyError: | ||
| pass | ||
| else: | ||
| current_loop_txs.append(raw_tx) | ||
| cursor = transaction['paging_token'] | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see a use for
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is used for the next request, line 220 |
||
|
|
||
| amount -= len(current_loop_txs) | ||
| tx_list.extend(current_loop_txs) | ||
| # if we got all the txs that we wanted, or there are no more txs | ||
| if amount <= 0 or len(horizon_response['_embedded']['records']) < requested_amount: | ||
| return tx_list | ||
|
|
||
| # If there are more transactions, loop again to get the next transaction page | ||
|
|
||
| async def friendbot(self, address: str) -> str: | ||
| """ | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm, why not append it as is (like you did in the
elsesection)?and log the error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's just the way the method works, if you only want simple txs it skips everything else