Files
mines/rin/proxy/stratum.js
Dobromir Popov e22f776e43 wip-broken
2025-09-21 21:22:18 +03:00

46 lines
1.4 KiB
JavaScript

var Server = require('stratum').Server;
// these settings can be changed using Server.defaults as well, for every new server up
var server = new Server({
/**
* The server settings itself
*/
settings: {
/**
* Address to set the X-Stratum header if someone connects using HTTP
* @type {String}
*/
hostname: 'localhost',
/**
* Max server lag before considering the server "too busy" and drop new connections
* @type {Number}
*/
toobusy : 70,
/**
* Bind to address, use 0.0.0.0 for external access
* @type {string}
*/
host : 'localhost',
/**
* Port for the stratum TCP server to listen on
* @type {Number}
*/
port : 3337
}
});
server.on('mining', function(req, deferred){
switch (req.method){
case 'subscribe':
// req.params[0] -> if filled, it's the User Agent, like CGMiner/CPUMiner sends
// Just resolve the deferred, the promise will be resolved and the data sent to the connected client
var difficulty_id = "b4b6693b72a50c7116db18d6497cac52";
var subscription_id = "ae6812eb4cd7735a302a8a9dd95cf71f";
var extranonce1 = "08000002";
var extranonce2_size = 4;
deferred.resolve([difficulty_id, subscription_id, extranonce1, extranonce2_size]);
break;
}
});
server.listen();