git ssb

2+

ev / mvd



Tree: 884eb5a57e543ca9344329d6f554bee248ddc66e

Files: 884eb5a57e543ca9344329d6f554bee248ddc66e / scuttlebot.js

891 bytesRaw
1var pull = require('pull-stream')
2var ssbKeys = require('ssb-keys')
3var ref = require('ssb-ref')
4var reconnect = require('pull-reconnect')
5
6var config = require('./config')()
7var createClient = require('ssb-client')
8var keys = require('./keys')
9
10var CACHE = {}
11
12var rec = reconnect(function (isConn) {
13 function notify (value) {
14 isConn(value)
15 }
16
17 createClient(keys, {
18 manifest: require('./manifest.json'),
19 remote: config.remote,
20 caps: config.caps
21 }, function (err, _sbot) {
22 if(err)
23 return notify(err)
24
25 sbot = _sbot
26 sbot.on('closed', function () {
27 sbot = null
28 notify(new Error('closed'))
29 })
30
31 notify()
32 })
33})
34
35module.exports = {
36 createLogStream: rec.source(function (opts) {
37 return pull(
38 sbot.createLogStream(opts),
39 pull.through(function (e) {
40 CACHE[e.key] = CACHE[e.key] || e.value
41 })
42 )
43 })
44}
45
46

Built with git-ssb-web