Skip to content

Commit f12c35b

Browse files
tabs
1 parent e6ea179 commit f12c35b

File tree

2 files changed

+80
-80
lines changed

2 files changed

+80
-80
lines changed

index.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ if (process.argv[2] == '-v' || process.argv[2] == '--version') {
2424
var iniFile = path.join(process.cwd(), 'config.ini');
2525

2626
if (!fs.existsSync(iniFile)) {
27-
console.log('Error : unable to locate ', iniFile);
28-
process.exit();
27+
console.log('Error : unable to locate ', iniFile);
28+
process.exit();
2929
}
3030

3131
var config = ini.parse(fs.readFileSync(iniFile, 'utf-8'));
@@ -41,25 +41,25 @@ async function init() {
4141
var stratumClient = new StratumClient(config);
4242

4343
if (!rpcServer) {
44-
rpcServer = new RPCServer(config);
44+
rpcServer = new RPCServer(config);
4545
}
4646

4747
// wait for shares from the miner and send them up to the pool. use the
4848
// callback to notify the miner if share was accepted.
49-
rpcServer.on('submitShare', async function(args, callback) {
50-
var res = await stratumClient.submitShare(args);
51-
callback(res);
52-
});
49+
rpcServer.on('submitShare', async function(args, callback) {
50+
var res = await stratumClient.submitShare(args);
51+
callback(res);
52+
});
5353

54-
// if we get disconnected from the pool, try to reconnect
54+
// if we get disconnected from the pool, try to reconnect
5555
stratumClient.on('disconnect', function() {
56-
rpcServer.removeAllListeners('submitShare');
56+
rpcServer.removeAllListeners('submitShare');
5757
LogB('Connection closed. Reconnecting in 5 seconds ...');
5858
setTimeout(init, 5000);
5959

6060
}).on('workPackage', function(params) {
61-
// listen for work packages from the stratum pool and make them available to the rpc server
62-
rpcServer.setWork(params);
61+
// listen for work packages from the stratum pool and make them available to the rpc server
62+
rpcServer.setWork(params);
6363
});
6464

6565
}

lib/rpc.js

Lines changed: 69 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -9,75 +9,75 @@ var LogB = global.logger.LogB;
99

1010
module.exports = class RPCServer extends EventEmitter {
1111

12-
constructor (config) {
12+
constructor (config) {
1313
super();
14-
var _this = this;
15-
16-
this.minerEthAddress = config.Miner.EthAddress.toLowerCase();
17-
this.mintingAccount = "";
18-
this.minerVarDiff = 0;
19-
this.minimumShareTarget = "";
20-
this.challengeNumber = "";
21-
22-
LogB('JSON-RPC server listening on localhost:' + config.RPC.Port);
23-
24-
// create an rpc server
25-
var server = jayson.server({
26-
27-
getPoolEthAddress: function(args, callback) {
28-
// LogB('getPoolEthAddress: ', args);
29-
callback(null, _this.mintingAccount);
30-
},
31-
32-
getMinimumShareDifficulty: async function(args, callback) {
33-
// LogB('getMinimumShareDifficulty: ', args);
34-
if (args[0].toLowerCase() != _this.minerEthAddress) {
35-
callback({code: -1, message: 'Invalid minerEthAddresss ' + args[0] + '. Expecting ' + _this.minerEthAddress});
36-
}
37-
callback(null, _this.minerVarDiff);
38-
},
39-
40-
getMinimumShareTarget: async function(args, callback) {
41-
// LogB('getMinimumShareTarget: ', args);
42-
if (args[0].toLowerCase() != _this.minerEthAddress) {
43-
callback({code: -1, message: 'Invalid minerEthAddresss ' + args[0] + '. Expecting ' + _this.minerEthAddress});
44-
}
45-
callback(null, _this.minimumShareTarget);
46-
},
47-
48-
getChallengeNumber: async function(args, callback) {
49-
// LogB('getChallengeNumber: ', args);
50-
callback(null, _this.challengeNumber);
51-
},
52-
53-
submitShare: async function(args, callback) {
54-
// LogB('submitShare: ', args);
55-
56-
// notify interested listeners of a share submit. provide a callback so we can be
57-
// notified if share was accepted (true/false).
58-
_this.emit('submitShare', args, (res) => {
59-
callback(null, res);
60-
})
61-
},
62-
63-
});
64-
65-
server.http().listen(config.RPC.Port);
66-
}
67-
68-
69-
setWork(params) {
70-
try {
71-
this.challengeNumber = params[0];
72-
this.minimumShareTarget = params[1];
73-
this.minerVarDiff = params[2];
74-
this.mintingAccount = params[3];
75-
}
76-
catch (err) {
77-
LogB('Error in setWork: unable to process mining pool work parameters');
78-
LogB('params=', params);
79-
}
80-
}
81-
14+
var _this = this;
15+
16+
this.minerEthAddress = config.Miner.EthAddress.toLowerCase();
17+
this.mintingAccount = "";
18+
this.minerVarDiff = 0;
19+
this.minimumShareTarget = "";
20+
this.challengeNumber = "";
21+
22+
LogB('JSON-RPC server listening on localhost:' + config.RPC.Port);
23+
24+
// create an rpc server
25+
var server = jayson.server({
26+
27+
getPoolEthAddress: function(args, callback) {
28+
// LogB('getPoolEthAddress: ', args);
29+
callback(null, _this.mintingAccount);
30+
},
31+
32+
getMinimumShareDifficulty: async function(args, callback) {
33+
// LogB('getMinimumShareDifficulty: ', args);
34+
if (args[0].toLowerCase() != _this.minerEthAddress) {
35+
callback({code: -1, message: 'Invalid minerEthAddresss ' + args[0] + '. Expecting ' + _this.minerEthAddress});
36+
}
37+
callback(null, _this.minerVarDiff);
38+
},
39+
40+
getMinimumShareTarget: async function(args, callback) {
41+
// LogB('getMinimumShareTarget: ', args);
42+
if (args[0].toLowerCase() != _this.minerEthAddress) {
43+
callback({code: -1, message: 'Invalid minerEthAddresss ' + args[0] + '. Expecting ' + _this.minerEthAddress});
44+
}
45+
callback(null, _this.minimumShareTarget);
46+
},
47+
48+
getChallengeNumber: async function(args, callback) {
49+
// LogB('getChallengeNumber: ', args);
50+
callback(null, _this.challengeNumber);
51+
},
52+
53+
submitShare: async function(args, callback) {
54+
// LogB('submitShare: ', args);
55+
56+
// notify interested listeners of a share submit. provide a callback so we can be
57+
// notified if share was accepted (true/false).
58+
_this.emit('submitShare', args, (res) => {
59+
callback(null, res);
60+
})
61+
},
62+
63+
});
64+
65+
server.http().listen(config.RPC.Port);
66+
}
67+
68+
69+
setWork(params) {
70+
try {
71+
this.challengeNumber = params[0];
72+
this.minimumShareTarget = params[1];
73+
this.minerVarDiff = params[2];
74+
this.mintingAccount = params[3];
75+
}
76+
catch (err) {
77+
LogB('Error in setWork: unable to process mining pool work parameters');
78+
LogB('params=', params);
79+
}
80+
}
81+
8282
}
8383

0 commit comments

Comments
 (0)