-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.js
85 lines (53 loc) · 1.75 KB
/
app.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
`use strict`;
const { createSecureServer } = require(`http2`);
const { createHash } = require(`crypto`);
const { readFileSync, statSync, writeFileSync } = require(`fs`);
const { Sql, Tools } = require(`./tools`);
const { Call, io, pollPay} = require(`./route`);
Sql.Sql([readFileSync(`constants/sql.sql`, {encoding: `utf8`}), () => {}]);
/**
Sql.pulls(Raw => {
Tools.values([Raw, (SQ) => {
Sql.putlist([`book`, SQ[0], (SQ) => {
Tools.execute([Raw, (Spot) => {
Sql.puts([`book`, Spot[0], (SQ) => {
Sql.putlist([`autospot`, Spot[1], (SQ) => {
if (Spot[2][0].open) {
Sql.places([`positions`, Spot[2][1], Spot[2][0], (State) => {
Tools.pairs([Raw, (Puts) => {
Sql.puts([`trades`, Puts[0], (SQ) => {
Sql.putlist([`till`, Puts[1], (SQ) => {}]);
}]);
}]);
}]);
}
if (Spot[0].side === `buy` && !Spot[2][0].open) {
let ts = new Date().valueOf();
let md = createHash(`md5`).update(`${ts}`, `utf8`).digest(`hex`)
Sql.puts([`positions`, {
close: [],
open: [Spot[0].pair[1][1], ts],
pair: Spot[0].pair[0], md: md, ts: ts}, (State) => {
Tools.pairs([Raw, (Puts) => {
Sql.puts([`trades`, Puts[0], (SQ) => {
Sql.putlist([`till`, Puts[1], (SQ) => {}]);
}]);
}]);
}]);
}
}]);
}]);
}]);
}]);
}]);
});
**/
let App = createSecureServer({
key: readFileSync(`http2/ssl/privkey.pem`),
cert: readFileSync(`http2/ssl/fullchain.pem`),
allowHTTP1: true}, (call, put) => {Call([call, put]);});
App.on(`error`, (err) => console.error(err));
App.listen(8124);
pollPay();
Tools.spot([(Spot) => {/*Sql.putlist([`book`, Spot[0], (SQ) => {}]);*/}]);
io(require(`socket.io`)(App));