|
|
|
@ -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();
|
|
|
|
|