-
Notifications
You must be signed in to change notification settings - Fork 9
/
start.js
59 lines (50 loc) · 1.57 KB
/
start.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
'use strict';
const
Stratum = require('./libs/class.Stratum'),
ChainParams = require('./libs/const.ChainParams');
const stratum = new Stratum({
chainParams: ChainParams.REGTEST, // Use ChainParams.MAIN for main net, ChainParams.TESTNET for testnet
coinbaseAddress: 'TC6qME2GhepR7656DgsR72pkQDmhfTDbtV',
blockBrand: '/@mintpond/ref-stratum/',
host: "0.0.0.0",
port: {
number: 3000,
diff: 10
},
rpc: {
host: '127.0.0.1',
port: 8888,
user: 'rpcuser',
password: 'x'
},
jobUpdateInterval: 55,
blockPollIntervalMs: 250
});
stratum.init();
stratum.on(Stratum.EVENT_CLIENT_CONNECT, ev => {
console.log(`Client connected: ${ev.client.socket.remoteAddress}`);
});
stratum.on(Stratum.EVENT_CLIENT_DISCONNECT, ev => {
console.log(`Client disconnected: ${ev.client.socket.remoteAddress} ${ev.reason}`);
});
stratum.on(Stratum.EVENT_SHARE_SUBMITTED, ev => {
if (ev.share.isValidBlock) {
console.log(`Valid block submitted by ${ev.share.client.workerName}`)
}
else if (ev.share.isValidShare) {
console.log(`Valid share submitted by ${ev.share.client.workerName}`)
}
else {
console.log(`Invalid share submitted by ${ev.share.client.workerName} ${ev.share.error.message}`)
}
});
// Make sure Error can be JSON serialized
if (!Error.prototype.toJSON) {
Error.prototype.toJSON = function () {
const jsonObj = {};
Object.getOwnPropertyNames(this).forEach(key => {
jsonObj[key] = this[key];
}, this);
return jsonObj;
}
}