From 21ba152429e57cb253606918f4eae66767fcf8df Mon Sep 17 00:00:00 2001 From: Alexander Blair Date: Fri, 19 May 2017 17:08:47 -0700 Subject: [PATCH] Update with the new share handling system. --- lib/local_comms.js | 9 ++++----- lib/remoteShare.js | 5 ++--- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index 19829e8..af64412 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -189,14 +189,13 @@ function Database(){ let shares = {}; // Shares keyed by blockID let shareCount = 0; debug(shareObject.length + ' shares to process'); - shareObject.forEach(function(data){ + shareObject.forEach(function(share){ //Data is the share object at this point. - let share = global.protos.Share.decode(data); shareCount += 1; if (!shares.hasOwnProperty(share.blockHeight)){ shares[share.blockHeight] = []; } - shares[share.blockHeight].push(data); + shares[share.blockHeight].push(share); let minerID = share.paymentAddress; if (typeof(share.paymentID) !== 'undefined' && share.paymentID.length > 10) { minerID = minerID + '.' + share.paymentID; @@ -273,9 +272,9 @@ function Database(){ if (shares.hasOwnProperty(key)){ blocksSeen += 1; let sharesSeen = 0; - shares[key].forEach(function(share){ + shares[key].forEach(function(final_share){ sharesSeen += 1; - txn.putBinary(global.database.shareDB, key, share); + txn.putBinary(global.database.shareDB, key, global.protos.Share.encode(final_share)); if (Object.keys(shares).length === blocksSeen && sharesSeen === shares[key].length){ debug('Made it to where I can do the insert'); txn.commit(); diff --git a/lib/remoteShare.js b/lib/remoteShare.js index 4d9a905..0dc884f 100644 --- a/lib/remoteShare.js +++ b/lib/remoteShare.js @@ -24,7 +24,7 @@ app.use(function(req, res, next){ // Master/Slave communication Handling function messageHandler(message) { - shareData.push(message.data); + shareData.push(message); } process.on('message', messageHandler); @@ -38,8 +38,7 @@ app.post('/leafApi', function (req, res) { switch (msgData.msgType) { case global.protos.MESSAGETYPE.SHARE: try { - global.protos.Share.decode(msgData.msg); - process.send({block: msgData.exInt, data: msgData.msg}); + process.send(global.protos.Share.decode(msgData.msg)); } catch (e){ } return res.json({'success': true});