MCPcopy Create free account
hub / github.com/Snipa22/nodejs-pool / templateUpdate

Function templateUpdate

lib/pool.js:157–180  ·  view source on GitHub ↗
(repeating)

Source from the content-addressed store, hash-verified

155}
156
157function 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
182function newBlockTemplate(template) {
183 let buffer = new Buffer(template.blocktemplate_blob, 'hex');

Callers 2

processShareFunction · 0.85
pool.jsFile · 0.85

Calls 2

sendToWorkersFunction · 0.85
newBlockTemplateFunction · 0.85

Tested by

no test coverage detected