mirror of
https://github.com/jwinterm/nodejs-pool.git
synced 2026-10-17 05:21:27 +02:00
Update with the new share handling system.
This commit is contained in:
+4
-5
@@ -189,14 +189,13 @@ function Database(){
|
|||||||
let shares = {}; // Shares keyed by blockID
|
let shares = {}; // Shares keyed by blockID
|
||||||
let shareCount = 0;
|
let shareCount = 0;
|
||||||
debug(shareObject.length + ' shares to process');
|
debug(shareObject.length + ' shares to process');
|
||||||
shareObject.forEach(function(data){
|
shareObject.forEach(function(share){
|
||||||
//Data is the share object at this point.
|
//Data is the share object at this point.
|
||||||
let share = global.protos.Share.decode(data);
|
|
||||||
shareCount += 1;
|
shareCount += 1;
|
||||||
if (!shares.hasOwnProperty(share.blockHeight)){
|
if (!shares.hasOwnProperty(share.blockHeight)){
|
||||||
shares[share.blockHeight] = [];
|
shares[share.blockHeight] = [];
|
||||||
}
|
}
|
||||||
shares[share.blockHeight].push(data);
|
shares[share.blockHeight].push(share);
|
||||||
let minerID = share.paymentAddress;
|
let minerID = share.paymentAddress;
|
||||||
if (typeof(share.paymentID) !== 'undefined' && share.paymentID.length > 10) {
|
if (typeof(share.paymentID) !== 'undefined' && share.paymentID.length > 10) {
|
||||||
minerID = minerID + '.' + share.paymentID;
|
minerID = minerID + '.' + share.paymentID;
|
||||||
@@ -273,9 +272,9 @@ function Database(){
|
|||||||
if (shares.hasOwnProperty(key)){
|
if (shares.hasOwnProperty(key)){
|
||||||
blocksSeen += 1;
|
blocksSeen += 1;
|
||||||
let sharesSeen = 0;
|
let sharesSeen = 0;
|
||||||
shares[key].forEach(function(share){
|
shares[key].forEach(function(final_share){
|
||||||
sharesSeen += 1;
|
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){
|
if (Object.keys(shares).length === blocksSeen && sharesSeen === shares[key].length){
|
||||||
debug('Made it to where I can do the insert');
|
debug('Made it to where I can do the insert');
|
||||||
txn.commit();
|
txn.commit();
|
||||||
|
|||||||
+2
-3
@@ -24,7 +24,7 @@ app.use(function(req, res, next){
|
|||||||
|
|
||||||
// Master/Slave communication Handling
|
// Master/Slave communication Handling
|
||||||
function messageHandler(message) {
|
function messageHandler(message) {
|
||||||
shareData.push(message.data);
|
shareData.push(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
process.on('message', messageHandler);
|
process.on('message', messageHandler);
|
||||||
@@ -38,8 +38,7 @@ app.post('/leafApi', function (req, res) {
|
|||||||
switch (msgData.msgType) {
|
switch (msgData.msgType) {
|
||||||
case global.protos.MESSAGETYPE.SHARE:
|
case global.protos.MESSAGETYPE.SHARE:
|
||||||
try {
|
try {
|
||||||
global.protos.Share.decode(msgData.msg);
|
process.send(global.protos.Share.decode(msgData.msg));
|
||||||
process.send({block: msgData.exInt, data: msgData.msg});
|
|
||||||
} catch (e){
|
} catch (e){
|
||||||
}
|
}
|
||||||
return res.json({'success': true});
|
return res.json({'success': true});
|
||||||
|
|||||||
Reference in New Issue
Block a user