Commit 42288cf44aa8aaf32d1036942ee30c6730803575
only prioritize pubs that we actually follow
ssbc/scuttlebot#445Matt McKegg committed on 10/28/2017, 10:06:22 AM
Parent: 8d409051a8f9c8f004d964d1c5cac5e5b8649a01
Files changed
sbot/index.js | changed |
sbot/index.js | ||
---|---|---|
@@ -37,27 +37,19 @@ | ||
37 | 37 | var roots = Roots(ssb, config) |
38 | 38 | var search = Search(ssb, config) |
39 | 39 | var recentFeeds = RecentFeeds(ssb, config) |
40 | 40 | |
41 | + // prioritize pubs that we actually follow | |
41 | 42 | 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) { | |
43 | + ssb.friends.createFriendStream({hops: 1, live: false}), | |
44 | + pull.collect((err, contacts) => { | |
45 | + if (!err) { | |
46 | 46 | ssb.gossip.peers().forEach(function (peer) { |
47 | - if (following[peer.key]) { | |
48 | - // we follow them, or follow someone that follows them! | |
47 | + if (contacts.includes(peer.key)) { | |
49 | 48 | 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 | 49 | } |
58 | 50 | }) |
59 | - }) | |
51 | + } | |
60 | 52 | }) |
61 | 53 | ) |
62 | 54 | |
63 | 55 | return { |
Built with git-ssb-web