MCPcopy Create free account
hub / github.com/ddimaria/rust-blockchain-tutorial / get_block_by_number

Method get_block_by_number

chain/src/blockchain.rs:52–60  ·  view source on GitHub ↗
(&self, block_number: U64)

Source from the content-addressed store, hash-verified

50 }
51
52 pub(crate) fn get_block_by_number(&self, block_number: U64) -> Result<Block> {
53 let index = (block_number - 1).as_usize();
54 let block = self
55 .blocks
56 .get(index)
57 .ok_or_else(|| ChainError::BlockNotFound("current block".into()))?;
58
59 Ok(block.to_owned())
60 }
61
62 pub(crate) fn parse_block_number(&self, block_number: &str) -> Result<BlockNumber> {
63 if block_number == "latest" {

Callers 2

new_blockMethod · 0.80
eth_get_block_by_numberFunction · 0.80

Calls 1

getMethod · 0.80

Tested by

no test coverage detected