-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart.js
56 lines (47 loc) · 1.41 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
'use strict';
const Stratum = require('./libs/class.Stratum');
const stratum = new Stratum({
coinbaseAddress: 'n1W99FwjX2HgBxVN9aYvpn91uhZfi9B8fj',
blockBrand: '/@mintpond/ref-stratum/',
host: "0.0.0.0",
port: {
number: 3010,
diff: 10
},
rpc: {
host: '172.0.0.1',
port: 18444,
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;
}
}