-
Notifications
You must be signed in to change notification settings - Fork 49
/
constants.js
62 lines (55 loc) · 1.18 KB
/
constants.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
const crypto = require('hypercore-crypto')
const COMMANDS = exports.COMMANDS = {
PEER_HANDSHAKE: 0,
PEER_HOLEPUNCH: 1,
FIND_PEER: 2,
LOOKUP: 3,
ANNOUNCE: 4,
UNANNOUNCE: 5,
MUTABLE_PUT: 6,
MUTABLE_GET: 7,
IMMUTABLE_PUT: 8,
IMMUTABLE_GET: 9
}
exports.BOOTSTRAP_NODES = global.Pear?.config.dht?.bootstrap || [
'[email protected]:49737',
'[email protected]:49737',
'[email protected]:49737'
]
exports.KNOWN_NODES = global.Pear?.config.dht?.nodes || []
exports.FIREWALL = {
UNKNOWN: 0,
OPEN: 1,
CONSISTENT: 2,
RANDOM: 3
}
exports.ERROR = {
// noise / connection related
NONE: 0,
ABORTED: 1,
VERSION_MISMATCH: 2,
TRY_LATER: 3,
// dht related
SEQ_REUSED: 16,
SEQ_TOO_LOW: 17
}
const [
NS_ANNOUNCE,
NS_UNANNOUNCE,
NS_MUTABLE_PUT,
NS_PEER_HANDSHAKE,
NS_PEER_HOLEPUNCH
] = crypto.namespace('hyperswarm/dht', [
COMMANDS.ANNOUNCE,
COMMANDS.UNANNOUNCE,
COMMANDS.MUTABLE_PUT,
COMMANDS.PEER_HANDSHAKE,
COMMANDS.PEER_HOLEPUNCH
])
exports.NS = {
ANNOUNCE: NS_ANNOUNCE,
UNANNOUNCE: NS_UNANNOUNCE,
MUTABLE_PUT: NS_MUTABLE_PUT,
PEER_HANDSHAKE: NS_PEER_HANDSHAKE,
PEER_HOLEPUNCH: NS_PEER_HOLEPUNCH
}