-
Notifications
You must be signed in to change notification settings - Fork 26
/
run.js
46 lines (31 loc) · 941 Bytes
/
run.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
var http = require('http');
var express = require('express');
var bodyParser = require('body-parser');
var app = express();
var shareHandler = require("./shareHandler.js");
app.use(bodyParser.json()); // for parsing application/json
app.post("/:address/:mh", function(req,res){
if(req.body.method === "eth_getWork"){
var mh = req.params.mh;
var address = req.params.address;
mh = (isNaN(parseInt(mh)) ? 1 : parseInt(mh));
mh = Math.max(1, mh);
mh = Math.min(mh, 9000);
shareHandler.getWork(res, mh);
}
else if(req.body.method === "eth_submitWork"){
var mh = req.params.mh;
mh = (isNaN(parseInt(mh)) ? 1 : parseInt(mh));
mh = Math.max(1, mh);
mh = Math.min(mh, 9000);
shareHandler.submitShare(req, res, mh);
}
else if(req.body.method === "eth_submitHashrate"){
shareHandler.submitHashrate(req, res);
}
else {
res.send("error");
}
});
//start the mining server on port 6555
app.listen(6555);