-
Notifications
You must be signed in to change notification settings - Fork 8
/
core.js
37 lines (29 loc) · 986 Bytes
/
core.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
exports.init = function (dir, config, extraModules) {
const EventEmitter = require('events')
SSBLOADER = new EventEmitter()
// init secret stack
const s = require('sodium-browserify')
s.events.on('sodium-browserify:wasm loaded', () => {
console.log("wasm loaded")
SSB = require('./net').init(dir, config, extraModules)
console.log("my id: ", SSB.id)
const helpers = require('./core-helpers')
SSB.helpers = {
box: require('ssb-keys').box,
connectAndRemember: helpers.connectAndRemember,
getPeer: helpers.getPeer,
convertHopsIntoGraph: helpers.convertHopsIntoGraph,
getGraphForFeed: helpers.getGraphForFeed,
removeDB: helpers.removeDB,
removeBlobs: helpers.removeBlobs
}
// delay startup a bit
const startOffline = config && config.core && config.core.startOffline
if (!startOffline) {
setTimeout(() => {
SSB.conn.start()
}, 2500)
}
SSBLOADER.emit("ready")
})
}