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

Method get_current_block

chain/src/blockchain.rs:43–50  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

41 }
42
43 pub(crate) fn get_current_block(&self) -> Result<Block> {
44 let block = self
45 .blocks
46 .last()
47 .ok_or_else(|| ChainError::BlockNotFound("current block".into()))?;
48
49 Ok(block.to_owned())
50 }
51
52 pub(crate) fn get_block_by_number(&self, block_number: U64) -> Result<Block> {
53 let index = (block_number - 1).as_usize();

Callers 5

parse_block_numberMethod · 0.80
new_blockMethod · 0.80
creates_and_gets_a_blockFunction · 0.80
eth_block_numberFunction · 0.80
eth_get_balanceFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected