If share.shares is not a number, don't try to add it to the processing list.

This commit is contained in:
Alexander Blair
2017-05-19 17:43:58 -07:00
parent 7e800538d8
commit 6413b89345
+15 -13
View File
@@ -192,7 +192,8 @@ function Database(){
shareObject.forEach(function(share){
//Data is the share object at this point.
shareCount += 1;
if (!shares.hasOwnProperty(share.blockHeight)){
if (typeof(share.shares) === "number") {
if (!shares.hasOwnProperty(share.blockHeight)) {
shares[share.blockHeight] = [];
}
shares[share.blockHeight].push(share);
@@ -202,10 +203,10 @@ function Database(){
}
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){
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){
if (!cachedData.global_stats.hasOwnProperty('roundHashes') || cachedData.global_stats.roundHashes === null) {
cachedData.global_stats.roundHashes = 0;
}
cachedData.global_stats.totalHashes += share.shares;
@@ -222,44 +223,45 @@ function Database(){
stats_type = 'solo_stats';
break;
}
if (!cachedData[stats_type].hasOwnProperty('totalHashes') || cachedData[stats_type].totalHashes === null){
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){
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)){
if (!cachedData.hasOwnProperty(minerID)) {
let minerCache = global.database.getCache(minerID);
if (minerCache === false){
if (minerCache === false) {
minerCache = {totalHashes: 0, goodShares: 0};
}
cachedData[minerID] = minerCache;
}
if (!cachedData.hasOwnProperty(minerIDWithIdentifier)){
if (!cachedData.hasOwnProperty(minerIDWithIdentifier)) {
let minerCache = global.database.getCache(minerIDWithIdentifier);
if (minerCache === false){
if (minerCache === false) {
minerCache = {totalHashes: 0, goodShares: 0};
}
cachedData[minerIDWithIdentifier] = minerCache;
}
if (!cachedData[minerIDWithIdentifier].hasOwnProperty('totalHashes') || cachedData[minerIDWithIdentifier].totalHashes === null){
if (!cachedData[minerIDWithIdentifier].hasOwnProperty('totalHashes') || cachedData[minerIDWithIdentifier].totalHashes === null) {
cachedData[minerIDWithIdentifier].totalHashes = 0;
}
if (!cachedData[minerIDWithIdentifier].hasOwnProperty('goodShares') || cachedData[minerIDWithIdentifier].goodShares === null){
if (!cachedData[minerIDWithIdentifier].hasOwnProperty('goodShares') || cachedData[minerIDWithIdentifier].goodShares === null) {
cachedData[minerIDWithIdentifier].goodShares = 0;
}
if (!cachedData[minerID].hasOwnProperty('totalHashes') || cachedData[minerID].totalHashes === null){
if (!cachedData[minerID].hasOwnProperty('totalHashes') || cachedData[minerID].totalHashes === null) {
cachedData[minerID].totalHashes = 0;
}
if (!cachedData[minerID].hasOwnProperty('goodShares') || cachedData[minerID].goodShares === null){
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();