Fixed mpos compatibility layer
This commit is contained in:
parent
b0f70f840f
commit
c7e61d681b
|
@ -1,5 +1,5 @@
|
|||
var mysql = require('mysql');
|
||||
|
||||
var cluster = require('cluster');
|
||||
module.exports = function(logger, poolConfigs){
|
||||
|
||||
var dbConnections = (function(){
|
||||
|
@ -92,14 +92,24 @@ module.exports = function(logger, poolConfigs){
|
|||
|
||||
};
|
||||
|
||||
this.handleShare = function(isValidShare, isValidBlock, data){
|
||||
|
||||
this.handleShare = function(data){
|
||||
var isValidShare = data.isValidShare;
|
||||
var isValidBlock = data.isValidBlock;
|
||||
if ((!data.coin in dbConnections)) return;
|
||||
|
||||
var connection = dbConnections[data.coin];
|
||||
var dbData = [
|
||||
data.share.ip,
|
||||
data.share.worker,
|
||||
isValidShare ? 'Y' : 'N',
|
||||
isValidBlock ? 'Y' : 'N',
|
||||
data.share.difficulty,
|
||||
typeof(data.share.error)==='undefined'?null:data.share.error,
|
||||
typeof(data.solution)==='undefined'?'':data.solution // solution?
|
||||
];
|
||||
connection.query(
|
||||
'INSERT INTO `shares` SET time = NOW(), rem_host = ?, username = ?, our_result = ?, upstream_result = ?, difficulty = ?, reason = ?, solution = ?',
|
||||
[data.ip, data.worker, isValidShare ? 'Y' : 'N', isValidBlock ? 'Y' : 'N', data.difficulty, data.error, data.solution],
|
||||
dbData,
|
||||
function(err, result) {
|
||||
if (err)
|
||||
logger.logError('shareProcessor', 'mysql', 'MySQL insert error when adding share: ' +
|
||||
|
|
|
@ -28,8 +28,9 @@ module.exports = function(logger){
|
|||
break;
|
||||
case 'mposAuth':
|
||||
var callbackId = message.callbackId;
|
||||
if (callbackId in mposAuthCallbacks)
|
||||
if (callbackId in mposAuthCallbacks) {
|
||||
mposAuthCallbacks[callbackId](message.authorized);
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
@ -93,7 +94,7 @@ module.exports = function(logger){
|
|||
|
||||
|
||||
var pool = Stratum.createPool(poolOptions, authorizeFN);
|
||||
pool.on('share', function(isValidShare, isValidBlock, data){
|
||||
pool.on('share', function(isValidShare, isValidBlock, data, blockHex){
|
||||
|
||||
var shareData = JSON.stringify(data);
|
||||
|
||||
|
@ -107,17 +108,18 @@ module.exports = function(logger){
|
|||
logDebug(logIdentify, 'client', 'Valid share submitted, share data: ' + shareData);
|
||||
process.send({
|
||||
type: 'share',
|
||||
share: shareData,
|
||||
share: data,
|
||||
coin: poolOptions.coin.name,
|
||||
isValidShare: isValidShare,
|
||||
isValidBlock: isValidBlock
|
||||
isValidBlock: isValidBlock,
|
||||
solution: blockHex
|
||||
});
|
||||
|
||||
if (isValidBlock){
|
||||
logDebug(logIdentify, 'client', 'Block found, solution: ' + shareData.solution);
|
||||
process.send({
|
||||
type: 'block',
|
||||
share: shareData,
|
||||
share: data,
|
||||
coin: poolOptions.coin.name
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue