-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
31 lines (28 loc) · 822 Bytes
/
index.js
File metadata and controls
31 lines (28 loc) · 822 Bytes
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
const jayson = require('jayson');
const {startMining, stopMining, poolTransaction} = require('./mine');
const {PORT} = require('./config');
const {utxos} = require('./db');
// create a server
const server = jayson.server({
startMining: function(_, callback) {
callback(null, 'success!');
startMining();
},
stopMining: function(_, callback) {
callback(null, 'success!');
stopMining();
},
poolTransaction: function([from, to, amount], callback) {
callback(null, 'success!');
poolTransaction([from, to, amount]);
},
/**
getBalance: function([address], callback) {
const ourUTXOs = utxos.filter(x => {
return x.owner === address && !x.spent;
});
const sum = ourUTXOs.reduce((p,c) => p + c.amount, 0);
callback(null, sum);
}*/
});
server.http().listen(PORT);