Skip to content

Commit

Permalink
feat: optimize _yield_tokens_at_block
Browse files Browse the repository at this point in the history
  • Loading branch information
BobTheBuidler authored Nov 26, 2024
1 parent 3ed5888 commit 55292fe
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions eth_portfolio/_ledgers/address.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,9 +630,10 @@ async def _yield_tokens_at_block(self, block: Optional[int] = None) -> AsyncIter
"""
yielded = set()
async for transfer in self[:block]:
if transfer.token_address not in yielded:
yielded.add(transfer.token_address)
yield ERC20(transfer.token_address, asynchronous=self.asynchronous)
address = transfer.token_address
if address not in yielded:
yielded.add(address)
yield ERC20(address, asynchronous=self.asynchronous)

@set_end_block_if_none
@stuck_coro_debugger
Expand Down

0 comments on commit 55292fe

Please sign in to comment.