MCPcopy Create free account
hub / github.com/QMHTMY/RustBook / mining

Method mining

code/chapter09/blockchain/blockchain7/core/src/mine.rs:21–31  ·  view source on GitHub ↗
(&mut self, txs: &mut Vec<Transaction>)

Source from the content-addressed store, hash-verified

19 }
20
21 pub fn mining(&mut self, txs: &mut Vec<Transaction>) {
22 // 准备 pre_hash 和难度值
23 let pre_hash = self.blockchain.curr_hash.clone();
24 let bits = self.blockchain.curr_bits.clone();
25
26 // 核心代码点:开始挖矿
27 let block = self.miner.mine_block(txs, pre_hash, bits);
28
29 // 区块保存
30 self.blockchain.add_block(block);
31 }
32}

Callers 1

mainFunction · 0.45

Calls 2

mine_blockMethod · 0.45
add_blockMethod · 0.45

Tested by

no test coverage detected