First and raw api support + mposcompatibility fixes/codereadability improvements
This commit is contained in:
parent
c7e61d681b
commit
1c6f7c4f50
|
@ -0,0 +1,18 @@
|
|||
var express = require('express');
|
||||
var os = require('os');
|
||||
var app = express();
|
||||
|
||||
app.get('/getstatus', function (req, res) {
|
||||
res.send({
|
||||
'loadavg': os.loadavg(),
|
||||
'freemem': os.freemem(),
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
module.exports = {
|
||||
start: function () {
|
||||
app.listen(9000);
|
||||
}
|
||||
}
|
||||
|
|
@ -84,6 +84,7 @@ module.exports = function(logger){
|
|||
});
|
||||
}
|
||||
else{
|
||||
// if we're here than it means we're on stratumAuth: "none" or something unrecognized by the system!
|
||||
callback({
|
||||
error: null,
|
||||
authorized: true,
|
||||
|
@ -112,7 +113,7 @@ module.exports = function(logger){
|
|||
coin : poolOptions.coin.name,
|
||||
isValidShare : isValidShare,
|
||||
isValidBlock : isValidBlock,
|
||||
solution: blockHex
|
||||
solution : blockHex // blockHex is undefined is this was not a valid block.
|
||||
});
|
||||
|
||||
if (isValidBlock){
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
var express = require('express');
|
||||
var os = require('os');
|
||||
|
||||
|
||||
function workerapi(listen) {
|
||||
var _this = this;
|
||||
var app = express();
|
||||
var counters = {
|
||||
validShares : 0,
|
||||
validBlocks : 0,
|
||||
invalidShares : 0
|
||||
};
|
||||
|
||||
var lastEvents = {
|
||||
lastValidShare : 0 ,
|
||||
lastValidBlock : 0,
|
||||
lastInvalidShare : 0
|
||||
};
|
||||
|
||||
app.get('/stats', function (req, res) {
|
||||
res.send({
|
||||
"clients" : Object.keys(_this.poolObj.stratumServer.getStratumClients()).length,
|
||||
"counters" : counters,
|
||||
"lastEvents" : lastEvents
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
this.start = function (poolObj) {
|
||||
this.poolObj = poolObj;
|
||||
this.poolObj.once('started', function () {
|
||||
app.listen(listen, function (lol) {
|
||||
console.log("LISTENING ");
|
||||
});
|
||||
})
|
||||
.on('share', function(isValidShare, isValidBlock, shareData) {
|
||||
var now = Date.now();
|
||||
if (isValidShare) {
|
||||
counters.validShares ++;
|
||||
lastEvents.lastValidShare = now;
|
||||
if (isValidBlock) {
|
||||
counters.validBlocks ++;
|
||||
lastEvents.lastValidBlock = now;
|
||||
}
|
||||
} else {
|
||||
counters.invalidShares ++;
|
||||
lastEvents.lastInvalidShare = now;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
module.exports = workerapi;
|
||||
|
Loading…
Reference in New Issue