git ssb

2+

ev / mvd



Tree: b05c12ba850a6a9d4f5af6d9f32136f3baf5d75f

Files: b05c12ba850a6a9d4f5af6d9f32136f3baf5d75f / scuttlebot.js

970 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 query: rec.source(function (query) {
45 return sbot.query.read(query)
46 })
47}
48
49

Built with git-ssb-web