* 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)
| 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 |
no test coverage detected