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

Method new_block

chain/src/blockchain.rs:72–85  ·  view source on GitHub ↗
(
        &mut self,
        transactions: Vec<Transaction>,
        state_trie: H256,
    )

Source from the content-addressed store, hash-verified

70 }
71
72 pub(crate) fn new_block(
73 &mut self,
74 transactions: Vec<Transaction>,
75 state_trie: H256,
76 ) -> Result<Block> {
77 let current_block = self.get_current_block()?;
78 let number = current_block.number + 1_u64;
79 let parent_hash = current_block.block_hash()?;
80 let block = Block::new(number, parent_hash, transactions, state_trie)?;
81
82 self.blocks.push(block);
83
84 self.get_block_by_number(number)
85 }
86
87 pub(crate) async fn send_transaction(
88 &mut self,

Callers 2

process_transactionsMethod · 0.80
creates_and_gets_a_blockFunction · 0.80

Calls 3

get_current_blockMethod · 0.80
block_hashMethod · 0.80
get_block_by_numberMethod · 0.80

Tested by

no test coverage detected