git ssb

0+

alanz / patchwork



forked from Matt McKegg / patchwork

Commit 42288cf44aa8aaf32d1036942ee30c6730803575

only prioritize pubs that we actually follow

ssbc/scuttlebot#445
Matt McKegg committed on 10/28/2017, 10:06:22 AM
Parent: 8d409051a8f9c8f004d964d1c5cac5e5b8649a01

Files changed

sbot/index.jschanged
sbot/index.jsView
@@ -37,27 +37,19 @@
3737 var roots = Roots(ssb, config)
3838 var search = Search(ssb, config)
3939 var recentFeeds = RecentFeeds(ssb, config)
4040
41+ // prioritize pubs that we actually follow
4142 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) {
4646 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)) {
4948 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- })
5749 }
5850 })
59- })
51+ }
6052 })
6153 )
6254
6355 return {

Built with git-ssb-web