From 55292fe74f9718d512162ae9464e64852718362d Mon Sep 17 00:00:00 2001 From: BobTheBuidler <70677534+BobTheBuidler@users.noreply.github.com> Date: Mon, 25 Nov 2024 20:55:02 -0400 Subject: [PATCH] feat: optimize _yield_tokens_at_block --- eth_portfolio/_ledgers/address.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/eth_portfolio/_ledgers/address.py b/eth_portfolio/_ledgers/address.py index 74867376..1366706c 100644 --- a/eth_portfolio/_ledgers/address.py +++ b/eth_portfolio/_ledgers/address.py @@ -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