From 792e63e151c921a60deabc8721df71f7759d0189 Mon Sep 17 00:00:00 2001 From: tkernell Date: Mon, 29 Jan 2024 14:11:12 -0600 Subject: [PATCH 1/2] handle bad api block height data --- src/telliot_feeds/sources/btc_balance.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/telliot_feeds/sources/btc_balance.py b/src/telliot_feeds/sources/btc_balance.py index 29c18424..5d5e43cc 100644 --- a/src/telliot_feeds/sources/btc_balance.py +++ b/src/telliot_feeds/sources/btc_balance.py @@ -76,6 +76,11 @@ async def get_response(self) -> Optional[Any]: logger.info("No transactions for this address") return 0 + for tx in data["txs"]: + if not tx.get("block_height") or not isinstance(tx["block_height"], int): + logger.error("Invalid transaction found: missing or non-integer block_height") + return None + # Sort transactions by time in ascending order sorted_txs = sorted(data["txs"], key=lambda tx: (tx["block_height"], tx["tx_index"])) From 2fbf989f76b03abc0a02f83b363601cfbdb9b689 Mon Sep 17 00:00:00 2001 From: tkernell Date: Mon, 29 Jan 2024 14:16:08 -0600 Subject: [PATCH 2/2] tox --- src/telliot_feeds/sources/btc_balance.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/telliot_feeds/sources/btc_balance.py b/src/telliot_feeds/sources/btc_balance.py index 5d5e43cc..d45fbcea 100644 --- a/src/telliot_feeds/sources/btc_balance.py +++ b/src/telliot_feeds/sources/btc_balance.py @@ -80,7 +80,7 @@ async def get_response(self) -> Optional[Any]: if not tx.get("block_height") or not isinstance(tx["block_height"], int): logger.error("Invalid transaction found: missing or non-integer block_height") return None - + # Sort transactions by time in ascending order sorted_txs = sorted(data["txs"], key=lambda tx: (tx["block_height"], tx["tx_index"]))