This commit is contained in:
tim
2024-07-26 02:29:59 -04:00
parent c661d7fb7b
commit 0786ec898b

View File

@@ -43,7 +43,7 @@ async def _fetch(fetch: FetchLock, chain_id: int, block_id: Union[int,bytes]) ->
if type(block_id) is int: if type(block_id) is int:
# by-number could return multiple results # by-number could return multiple results
# noinspection PyTypeChecker # noinspection PyTypeChecker
blocks: list[DbBlock] = db.session.execute(select(DbBlock).where( blocks: list[DbBlock] = db.session.scalars(select(DbBlock).where(
DbBlock.chain == chain, DbBlock.chain == chain,
DbBlock.height == block_id DbBlock.height == block_id
)).all() )).all()
@@ -53,7 +53,11 @@ async def _fetch(fetch: FetchLock, chain_id: int, block_id: Union[int,bytes]) ->
else: else:
found = db.session.get(DbBlock, dict(chain=chain, hash=block_id)) # by-hash is the primary key found = db.session.get(DbBlock, dict(chain=chain, hash=block_id)) # by-hash is the primary key
if found: 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 # fetch from RPC
try: try: