Update with the new share handling system.

This commit is contained in:
Alexander Blair
2017-05-19 17:08:47 -07:00
parent 063b206d46
commit 21ba152429
2 changed files with 6 additions and 8 deletions
+4 -5
View File
@@ -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();