git ssb

0+

alanz / patchwork



forked from Matt McKegg / patchwork

Tree: f6b15ef0c66ef8142dc6e63a6065df61a37573a2

Files: f6b15ef0c66ef8142dc6e63a6065df61a37573a2 / sbot / index.js

1817 bytesRaw
1var Channels = require('./channels')
2var Heartbeat = require('./heartbeat')
3var Subscriptions = require('./subscriptions')
4var Roots = require('./roots')
5var Progress = require('./progress')
6var Search = require('./search')
7var RecentFeeds = require('./recent-feeds')
8var LiveBacklinks = require('./live-backlinks')
9var pull = require('pull-stream')
10
11exports.name = 'patchwork'
12exports.version = require('../package.json').version
13exports.manifest = {
14 channels: 'source',
15 subscriptions: 'source',
16 roots: 'source',
17 latest: 'source',
18 linearSearch: 'source',
19 progress: 'source',
20 recentFeeds: 'source',
21 heartbeat: 'source',
22
23 getSubscriptions: 'async',
24 getChannels: 'async',
25
26 liveBacklinks: {
27 subscribe: 'sync',
28 unsubscribe: 'sync',
29 stream: 'source'
30 }
31}
32
33exports.init = function (ssb, config) {
34 var progress = Progress(ssb, config)
35 var channels = Channels(ssb, config)
36 var subscriptions = Subscriptions(ssb, config)
37 var roots = Roots(ssb, config)
38 var search = Search(ssb, config)
39 var recentFeeds = RecentFeeds(ssb, config)
40
41 // prioritize pubs that we actually follow
42 pull(
43 ssb.friends.createFriendStream({hops: 1, live: false}),
44 pull.collect((err, contacts) => {
45 if (!err) {
46 ssb.gossip.peers().forEach(function (peer) {
47 if (contacts.includes(peer.key)) {
48 ssb.gossip.add(peer, 'friends')
49 }
50 })
51 }
52 })
53 )
54
55 return {
56 heartbeat: Heartbeat(ssb, config),
57 channels: channels.stream,
58 subscriptions: subscriptions.stream,
59 roots: roots.read,
60 latest: roots.latest,
61 progress: progress.stream,
62 recentFeeds: recentFeeds.stream,
63 linearSearch: search.linear,
64 getSubscriptions: subscriptions.get,
65 getChannels: channels.get,
66 liveBacklinks: LiveBacklinks(ssb, config)
67 }
68}
69

Built with git-ssb-web