From 41920c5e2a856124a4b3460d18515d052bcba507 Mon Sep 17 00:00:00 2001 From: Alexander Blair Date: Mon, 16 Oct 2017 09:47:36 -0700 Subject: [PATCH] Adding todos to re-implement coin functions within the coins/coin.js file. --- lib/blockManager.js | 3 +++ lib/pool.js | 1 + lib/worker.js | 6 ++++++ 3 files changed, 10 insertions(+) diff --git a/lib/blockManager.js b/lib/blockManager.js index bea07e2..89fccc3 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -16,6 +16,7 @@ let lastBlock = 0; let balanceIDCache = {}; let blockScannerTask; let blockQueue = async.queue(function (task, callback) { + // Todo: Implement within the coins/.js file. global.support.rpcDaemon('getblockheaderbyheight', {"height": task.blockID}, function (body) { let blockData = body.result.block_header; if (blockData.hash in blockHexCache) { @@ -397,9 +398,11 @@ function blockUnlocker() { } debug("Running block unlocker"); let blockList = global.database.getValidLockedBlocks(); + // Todo: Implement within the coins/.js file. global.support.rpcDaemon('getlastblockheader', [], function (body) { let blockHeight = body.result.block_header.height; blockList.forEach(function (row) { + // Todo: Implement within the coins/.js file. global.support.rpcDaemon('getblockheaderbyheight', {"height": row.height}, function (body) { if (body.result.block_header.hash !== row.hash) { global.database.invalidateBlock(row.height); diff --git a/lib/pool.js b/lib/pool.js index 39eca5d..b0e1e46 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -622,6 +622,7 @@ function processShare(miner, job, blockTemplate, params) { if (hashDiff.ge(blockTemplate.difficulty)) { // Submit block to the RPC Daemon. + // Todo: Implement within the coins/.js file. global.support.rpcDaemon('submitblock', [shareBuffer.toString('hex')], function (rpcResult) { if (rpcResult.error) { // Did not manage to submit a block. Log and continue on. diff --git a/lib/worker.js b/lib/worker.js index fd4324a..8714ca9 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -431,6 +431,7 @@ function updatePoolInformation() { } function updateBlockHeader() { + // Todo: Implement within the coins/.js file. global.support.rpcDaemon('getlastblockheader', [], function (body) { if (typeof body.error !== 'undefined'){ return console.error(`Issue getting last block header: ${JSON.stringify(body)}`); @@ -455,6 +456,7 @@ function updateBlockHeader() { function updateWalletStats() { async.waterfall([ function (callback) { + // Todo: Implement within the coins/.js file. global.support.rpcWallet('getbalance', [], function (body) { if (body.result) { return callback(null, { @@ -468,10 +470,14 @@ function updateWalletStats() { }); }, function (state, callback) { + // Todo: Implement within the coins/.js file. global.support.rpcWallet('getheight', [], function (body) { if (body.result) { state.height = body.result.height; return callback(null, state); + } else if (typeof body.error !== 'undefined' && body.error.message === 'Method not found') { + state.height = 0; + return callback(null, state); } else { return callback(true, "Unable to get current wallet height"); }