perf: fetch total difficulty by block number (#3284)

This commit is contained in:
Matthias Seitz
2023-06-20 21:16:45 +02:00
committed by GitHub
parent c328c8234e
commit 0a752d741d

View File

@ -102,8 +102,10 @@ where
None => return Ok(None),
};
let block_hash = block.hash;
let total_difficulty =
self.provider().header_td(&block_hash)?.ok_or(EthApiError::UnknownBlockNumber)?;
let total_difficulty = self
.provider()
.header_td_by_number(block.number)?
.ok_or(EthApiError::UnknownBlockNumber)?;
let block =
Block::from_block(block.into(), total_difficulty, full.into(), Some(block_hash))?;
Ok(Some(block.into()))