From 761ce6ac018e4fbbb8356bef11a766005a525300 Mon Sep 17 00:00:00 2001 From: BobTheBuidler <70677534+BobTheBuidler@users.noreply.github.com> Date: Thu, 19 Dec 2024 23:46:21 -0400 Subject: [PATCH] fix: min arg is empty iterable --- eth_portfolio/_loaders/transaction.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/eth_portfolio/_loaders/transaction.py b/eth_portfolio/_loaders/transaction.py index f71da787..a9cc3948 100644 --- a/eth_portfolio/_loaders/transaction.py +++ b/eth_portfolio/_loaders/transaction.py @@ -109,7 +109,7 @@ async def get_block_for_nonce(address: Address, nonce: Nonce) -> int: lowest_known_nonce_greater_than_query = None # it is impossible for n to == nonce - for less_than, ns in itertools.groupby(nonces[address], lambda n: n < nonce): + for less_than, ns in itertools.groupby(filter(lambda n: n != nonce, nonces[address]), lambda n: n < nonce): if less_than: max_value = max(ns) if ( @@ -119,7 +119,10 @@ async def get_block_for_nonce(address: Address, nonce: Nonce) -> int: highest_known_nonce_lower_than_query = max_value else: - min_value = min(filter(lambda n: n > nonce, ns)) + try: + min_value = min(filter(lambda n: n > nonce, ns)) + except ValueError: + continue if ( lowest_known_nonce_greater_than_query is None or min_value < lowest_known_nonce_greater_than_query