Hush-flavored NOMP
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

56 lines
1.1 KiB

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;