From 0786ec898bbf727ff85a2b703c7781d930063a6d Mon Sep 17 00:00:00 2001 From: tim Date: Fri, 26 Jul 2024 02:29:59 -0400 Subject: [PATCH] bugfix --- src/dexorder/blocks.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/dexorder/blocks.py b/src/dexorder/blocks.py index aceb79c..8908e5e 100644 --- a/src/dexorder/blocks.py +++ b/src/dexorder/blocks.py @@ -43,7 +43,7 @@ async def _fetch(fetch: FetchLock, chain_id: int, block_id: Union[int,bytes]) -> if type(block_id) is int: # by-number could return multiple results # noinspection PyTypeChecker - blocks: list[DbBlock] = db.session.execute(select(DbBlock).where( + blocks: list[DbBlock] = db.session.scalars(select(DbBlock).where( DbBlock.chain == chain, DbBlock.height == block_id )).all() @@ -53,7 +53,11 @@ async def _fetch(fetch: FetchLock, chain_id: int, block_id: Union[int,bytes]) -> else: found = db.session.get(DbBlock, dict(chain=chain, hash=block_id)) # by-hash is the primary key if found: - return Block(chain_id, found.data) + log.debug(f'found block: {found}') + try: + return Block(chain_id, found.data) + except AttributeError: + log.exception(f'found was {found}') # fetch from RPC try: