Moving share validation into remoteShare before it ever gets to our internal processing DB loop.

This commit is contained in:
Alexander Blair
2017-05-19 16:54:20 -07:00
parent cdf17d4e70
commit 063b206d46
2 changed files with 10 additions and 2 deletions
+3 -1
View File
@@ -188,14 +188,15 @@ function Database(){
};
let shares = {}; // Shares keyed by blockID
let shareCount = 0;
debug(shareObject.length + ' shares to process');
shareObject.forEach(function(data){
//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);
shareCount += 1;
let minerID = share.paymentAddress;
if (typeof(share.paymentID) !== 'undefined' && share.paymentID.length > 10) {
minerID = minerID + '.' + share.paymentID;
@@ -276,6 +277,7 @@ function Database(){
sharesSeen += 1;
txn.putBinary(global.database.shareDB, key, share);
if (Object.keys(shares).length === blocksSeen && sharesSeen === shares[key].length){
debug('Made it to where I can do the insert');
txn.commit();
return true;
}