From 6413b8934554f9104dee751050f5bfa5ba2d60bd Mon Sep 17 00:00:00 2001 From: Alexander Blair Date: Fri, 19 May 2017 17:43:58 -0700 Subject: [PATCH] If share.shares is not a number, don't try to add it to the processing list. --- lib/local_comms.js | 132 +++++++++++++++++++++++---------------------- 1 file changed, 67 insertions(+), 65 deletions(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index b8410ab..1473357 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -192,74 +192,76 @@ function Database(){ shareObject.forEach(function(share){ //Data is the share object at this point. shareCount += 1; - if (!shares.hasOwnProperty(share.blockHeight)){ - shares[share.blockHeight] = []; - } - shares[share.blockHeight].push(share); - let minerID = share.paymentAddress; - if (typeof(share.paymentID) !== 'undefined' && share.paymentID.length > 10) { - minerID = minerID + '.' + share.paymentID; - } - let minerIDWithIdentifier = minerID + "_" + share.identifier; - // this.incrementCacheData('global_stats', [{location: 'totalHashes', value: share.shares}, {location: 'roundHashes', value: share.shares}]); - if (!cachedData.global_stats.hasOwnProperty('totalHashes') || cachedData.global_stats.totalHashes === null){ - cachedData.global_stats.totalHashes = 0; - } - if (!cachedData.global_stats.hasOwnProperty('roundHashes') || cachedData.global_stats.roundHashes === null){ - cachedData.global_stats.roundHashes = 0; - } - cachedData.global_stats.totalHashes += share.shares; - cachedData.global_stats.roundHashes += share.shares; - let stats_type = 'pplns_stats'; - switch (share.poolType) { - case global.protos.POOLTYPE.PPLNS: - stats_type = 'pplns_stats'; - break; - case global.protos.POOLTYPE.PPS: - stats_type = 'pps_stats'; - break; - case global.protos.POOLTYPE.SOLO: - stats_type = 'solo_stats'; - break; - } - if (!cachedData[stats_type].hasOwnProperty('totalHashes') || cachedData[stats_type].totalHashes === null){ - cachedData[stats_type].totalHashes = 0; - } - if (!cachedData[stats_type].hasOwnProperty('roundHashes') || cachedData[stats_type].roundHashes === null){ - cachedData[stats_type].roundHashes = 0; - } - cachedData[stats_type].totalHashes += share.shares; - cachedData[stats_type].roundHashes += share.shares; - if (!cachedData.hasOwnProperty(minerID)){ - let minerCache = global.database.getCache(minerID); - if (minerCache === false){ - minerCache = {totalHashes: 0, goodShares: 0}; + if (typeof(share.shares) === "number") { + if (!shares.hasOwnProperty(share.blockHeight)) { + shares[share.blockHeight] = []; } - cachedData[minerID] = minerCache; - } - if (!cachedData.hasOwnProperty(minerIDWithIdentifier)){ - let minerCache = global.database.getCache(minerIDWithIdentifier); - if (minerCache === false){ - minerCache = {totalHashes: 0, goodShares: 0}; + shares[share.blockHeight].push(share); + let minerID = share.paymentAddress; + if (typeof(share.paymentID) !== 'undefined' && share.paymentID.length > 10) { + minerID = minerID + '.' + share.paymentID; } - cachedData[minerIDWithIdentifier] = minerCache; + let minerIDWithIdentifier = minerID + "_" + share.identifier; + // this.incrementCacheData('global_stats', [{location: 'totalHashes', value: share.shares}, {location: 'roundHashes', value: share.shares}]); + if (!cachedData.global_stats.hasOwnProperty('totalHashes') || cachedData.global_stats.totalHashes === null) { + cachedData.global_stats.totalHashes = 0; + } + if (!cachedData.global_stats.hasOwnProperty('roundHashes') || cachedData.global_stats.roundHashes === null) { + cachedData.global_stats.roundHashes = 0; + } + cachedData.global_stats.totalHashes += share.shares; + cachedData.global_stats.roundHashes += share.shares; + let stats_type = 'pplns_stats'; + switch (share.poolType) { + case global.protos.POOLTYPE.PPLNS: + stats_type = 'pplns_stats'; + break; + case global.protos.POOLTYPE.PPS: + stats_type = 'pps_stats'; + break; + case global.protos.POOLTYPE.SOLO: + stats_type = 'solo_stats'; + break; + } + if (!cachedData[stats_type].hasOwnProperty('totalHashes') || cachedData[stats_type].totalHashes === null) { + cachedData[stats_type].totalHashes = 0; + } + if (!cachedData[stats_type].hasOwnProperty('roundHashes') || cachedData[stats_type].roundHashes === null) { + cachedData[stats_type].roundHashes = 0; + } + cachedData[stats_type].totalHashes += share.shares; + cachedData[stats_type].roundHashes += share.shares; + if (!cachedData.hasOwnProperty(minerID)) { + let minerCache = global.database.getCache(minerID); + if (minerCache === false) { + minerCache = {totalHashes: 0, goodShares: 0}; + } + cachedData[minerID] = minerCache; + } + if (!cachedData.hasOwnProperty(minerIDWithIdentifier)) { + let minerCache = global.database.getCache(minerIDWithIdentifier); + if (minerCache === false) { + minerCache = {totalHashes: 0, goodShares: 0}; + } + cachedData[minerIDWithIdentifier] = minerCache; + } + if (!cachedData[minerIDWithIdentifier].hasOwnProperty('totalHashes') || cachedData[minerIDWithIdentifier].totalHashes === null) { + cachedData[minerIDWithIdentifier].totalHashes = 0; + } + if (!cachedData[minerIDWithIdentifier].hasOwnProperty('goodShares') || cachedData[minerIDWithIdentifier].goodShares === null) { + cachedData[minerIDWithIdentifier].goodShares = 0; + } + if (!cachedData[minerID].hasOwnProperty('totalHashes') || cachedData[minerID].totalHashes === null) { + cachedData[minerID].totalHashes = 0; + } + if (!cachedData[minerID].hasOwnProperty('goodShares') || cachedData[minerID].goodShares === null) { + cachedData[minerID].goodShares = 0; + } + cachedData[minerIDWithIdentifier].totalHashes += share.shares; + cachedData[minerID].totalHashes += share.shares; + cachedData[minerIDWithIdentifier].goodShares += 1; + cachedData[minerID].goodShares += 1; } - if (!cachedData[minerIDWithIdentifier].hasOwnProperty('totalHashes') || cachedData[minerIDWithIdentifier].totalHashes === null){ - cachedData[minerIDWithIdentifier].totalHashes = 0; - } - if (!cachedData[minerIDWithIdentifier].hasOwnProperty('goodShares') || cachedData[minerIDWithIdentifier].goodShares === null){ - cachedData[minerIDWithIdentifier].goodShares = 0; - } - if (!cachedData[minerID].hasOwnProperty('totalHashes') || cachedData[minerID].totalHashes === null){ - cachedData[minerID].totalHashes = 0; - } - if (!cachedData[minerID].hasOwnProperty('goodShares') || cachedData[minerID].goodShares === null){ - cachedData[minerID].goodShares = 0; - } - cachedData[minerIDWithIdentifier].totalHashes += share.shares; - cachedData[minerID].totalHashes += share.shares; - cachedData[minerIDWithIdentifier].goodShares += 1; - cachedData[minerID].goodShares += 1; if(shareObject.length === shareCount){ // Perform insert and return let txn = global.database.env.beginTxn();