MCPcopy Index your code
hub / github.com/Savjee/SavjeeCoin / mineBlock

Method mineBlock

src/blockchain.js:113–122  ·  view source on GitHub ↗

* Starts the mining process on the block. It changes the 'nonce' until the hash * of the block starts with enough zeros (= difficulty) * * @param {number} difficulty

(difficulty)

Source from the content-addressed store, hash-verified

111 * @param {number} difficulty
112 */
113 mineBlock(difficulty) {
114 while (
115 this.hash.substring(0, difficulty) !== Array(difficulty + 1).join('0')
116 ) {
117 this.nonce++;
118 this.hash = this.calculateHash();
119 }
120
121 debug(`Block mined: ${this.hash}`);
122 }
123
124 /**
125 * Validates all the transactions inside this block (signature + hash) and

Callers 2

block.test.jsFile · 0.80

Calls 1

calculateHashMethod · 0.95

Tested by

no test coverage detected