diff --git a/lib/local_comms.js b/lib/local_comms.js index 733524b..b8410ab 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -201,10 +201,11 @@ function Database(){ minerID = minerID + '.' + share.paymentID; } let minerIDWithIdentifier = minerID + "_" + share.identifier; - if (!cachedData.global_stats.hasOwnProperty('totalHashes')){ + // 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')){ + if (!cachedData.global_stats.hasOwnProperty('roundHashes') || cachedData.global_stats.roundHashes === null){ cachedData.global_stats.roundHashes = 0; } cachedData.global_stats.totalHashes += share.shares; @@ -221,10 +222,10 @@ function Database(){ stats_type = 'solo_stats'; break; } - if (!cachedData[stats_type].hasOwnProperty('totalHashes')){ + if (!cachedData[stats_type].hasOwnProperty('totalHashes') || cachedData[stats_type].totalHashes === null){ cachedData[stats_type].totalHashes = 0; } - if (!cachedData[stats_type].hasOwnProperty('roundHashes')){ + if (!cachedData[stats_type].hasOwnProperty('roundHashes') || cachedData[stats_type].roundHashes === null){ cachedData[stats_type].roundHashes = 0; } cachedData[stats_type].totalHashes += share.shares; @@ -243,16 +244,16 @@ function Database(){ } cachedData[minerIDWithIdentifier] = minerCache; } - if (!cachedData[minerIDWithIdentifier].hasOwnProperty('totalHashes')){ + if (!cachedData[minerIDWithIdentifier].hasOwnProperty('totalHashes') || cachedData[minerIDWithIdentifier].totalHashes === null){ cachedData[minerIDWithIdentifier].totalHashes = 0; } - if (!cachedData[minerIDWithIdentifier].hasOwnProperty('goodShares')){ + if (!cachedData[minerIDWithIdentifier].hasOwnProperty('goodShares') || cachedData[minerIDWithIdentifier].goodShares === null){ cachedData[minerIDWithIdentifier].goodShares = 0; } - if (!cachedData[minerID].hasOwnProperty('totalHashes')){ + if (!cachedData[minerID].hasOwnProperty('totalHashes') || cachedData[minerID].totalHashes === null){ cachedData[minerID].totalHashes = 0; } - if (!cachedData[minerID].hasOwnProperty('goodShares')){ + if (!cachedData[minerID].hasOwnProperty('goodShares') || cachedData[minerID].goodShares === null){ cachedData[minerID].goodShares = 0; } cachedData[minerIDWithIdentifier].totalHashes += share.shares;