Update with the new share handling system.
This commit is contained in:
parent
063b206d46
commit
21ba152429
2 changed files with 6 additions and 8 deletions
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ app.use(function(req, res, next){
|
|||
|
||||
// Master/Slave communication Handling
|
||||
function messageHandler(message) {
|
||||
shareData.push(message.data);
|
||||
shareData.push(message);
|
||||
}
|
||||
|
||||
process.on('message', messageHandler);
|
||||
|
|
@ -38,8 +38,7 @@ app.post('/leafApi', function (req, res) {
|
|||
switch (msgData.msgType) {
|
||||
case global.protos.MESSAGETYPE.SHARE:
|
||||
try {
|
||||
global.protos.Share.decode(msgData.msg);
|
||||
process.send({block: msgData.exInt, data: msgData.msg});
|
||||
process.send(global.protos.Share.decode(msgData.msg));
|
||||
} catch (e){
|
||||
}
|
||||
return res.json({'success': true});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue