(repeating)
| 155 | } |
| 156 | |
| 157 | function templateUpdate(repeating) { |
| 158 | global.coinFuncs.getBlockTemplate(global.config.pool.address, function (rpcResponse) { |
| 159 | if (rpcResponse && typeof rpcResponse.result !== 'undefined') { |
| 160 | rpcResponse = rpcResponse.result; |
| 161 | let buffer = new Buffer(rpcResponse.blocktemplate_blob, 'hex'); |
| 162 | let new_hash = new Buffer(32); |
| 163 | buffer.copy(new_hash, 0, 7, 39); |
| 164 | if (!activeBlockTemplate || new_hash.toString('hex') !== activeBlockTemplate.previous_hash.toString('hex')) { |
| 165 | debug(threadName + "New block template found at " + rpcResponse.height + " height with hash: " + new_hash.toString('hex')); |
| 166 | if (cluster.isMaster) { |
| 167 | sendToWorkers({type: 'newBlockTemplate', data: rpcResponse}); |
| 168 | newBlockTemplate(rpcResponse); |
| 169 | } else { |
| 170 | process.send({type: 'newBlockTemplate', data: rpcResponse}); |
| 171 | newBlockTemplate(rpcResponse); |
| 172 | } |
| 173 | } |
| 174 | } else { |
| 175 | if (repeating !== true) { |
| 176 | setTimeout(templateUpdate, 300); |
| 177 | } |
| 178 | } |
| 179 | }); |
| 180 | } |
| 181 | |
| 182 | function newBlockTemplate(template) { |
| 183 | let buffer = new Buffer(template.blocktemplate_blob, 'hex'); |
no test coverage detected