Commit 2b1901f924e308bd0de810bbd4e8d894d91c2160
fix prioritize friend gossip
Matt McKegg committed on 10/18/2017, 2:20:34 PMParent: 76bc25fbc6edd50d2de53f58f3033960b0b32a34
Files changed
sbot/index.js | changed |
sbot/index.js | ||
---|---|---|
@@ -5,8 +5,9 @@ | ||
5 | 5 | var Progress = require('./progress') |
6 | 6 | var Search = require('./search') |
7 | 7 | var RecentFeeds = require('./recent-feeds') |
8 | 8 | var LiveBacklinks = require('./live-backlinks') |
9 | +var pull = require('pull-stream') | |
9 | 10 | |
10 | 11 | exports.name = 'patchwork' |
11 | 12 | exports.version = require('../package.json').version |
12 | 13 | exports.manifest = { |
@@ -36,8 +37,30 @@ | ||
36 | 37 | var roots = Roots(ssb, config) |
37 | 38 | var search = Search(ssb, config) |
38 | 39 | var recentFeeds = RecentFeeds(ssb, config) |
39 | 40 | |
41 | + pull( | |
42 | + ssb.friends.createFriendStream({live: false}), | |
43 | + pull.drain(() => {}, () => { | |
44 | + // don't assign peer friends until friends have loaded | |
45 | + ssb.friends.hops({start: ssb.id, hops: 2}, function (_, following) { | |
46 | + ssb.gossip.peers().forEach(function (peer) { | |
47 | + if (following[peer.key]) { | |
48 | + // we follow them, or follow someone that follows them! | |
49 | + ssb.gossip.add(peer, 'friends') | |
50 | + } else { | |
51 | + ssb.friends.hops({start: peer.key, hops: 2}, function (_, result) { | |
52 | + if (result && result[ssb.id]) { | |
53 | + // they follow us, or someone that follows us! | |
54 | + ssb.gossip.add(peer, 'friends') | |
55 | + } | |
56 | + }) | |
57 | + } | |
58 | + }) | |
59 | + }) | |
60 | + }) | |
61 | + ) | |
62 | + | |
40 | 63 | return { |
41 | 64 | heartbeat: Heartbeat(ssb, config), |
42 | 65 | channels: channels.stream, |
43 | 66 | subscriptions: subscriptions.stream, |
Built with git-ssb-web