Fix Newer block issue (#11486)

* Fix Newer block issue

* Fallback to checking memory
This commit is contained in:
Mariano Sorgente 2022-05-12 18:15:36 -04:00 committed by GitHub
parent 9a07247e1f
commit ce92f36055
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -470,7 +470,11 @@ class FullNodeRpcApi:
newer_block = await self.service.block_store.get_block_record(newer_block_bytes)
if newer_block is None:
raise ValueError(f"Newer block {newer_block_hex} not found")
# It's possible that the peak block has not yet been committed to the DB, so as a fallback, check memory
try:
newer_block = self.service.blockchain.block_record(newer_block_bytes)
except KeyError:
raise ValueError(f"Newer block {newer_block_hex} not found")
older_block = await self.service.block_store.get_block_record(older_block_bytes)
if older_block is None:
raise ValueError(f"Older block {older_block_hex} not found")