Commit 93c8acc3bef1de08c2824be1d2c5d39c33ec499d
tweak persistent-gossip to favour pubs that you are friends with, increase perm to 3
Matt McKegg committed on 11/2/2016, 9:25:50 PMParent: 9744d260b89e1e2afac37b36c0973c99040adefd
Files changed
lib/persistent-gossip/schedule.js | changed |
server-process.js | changed |
lib/persistent-gossip/schedule.js | ||
---|---|---|
@@ -145,9 +145,9 @@ | ||
145 | 145 | connecting = false |
146 | 146 | var ts = Date.now() |
147 | 147 | var peers = gossip.peers() |
148 | 148 | |
149 | - var connected = peers.filter(isConnect).length | |
149 | + var connected = peers.filter(and(isConnect, not(isLocal))).length | |
150 | 150 | |
151 | 151 | connect(peers, ts, 'longterm', exports.isLongterm, { |
152 | 152 | quota: 3, factor: 10e3, max: 10*min, groupMin: 5e3, |
153 | 153 | disable: !conf('global', true) |
@@ -157,13 +157,14 @@ | ||
157 | 157 | quota: 3, factor: 2e3, max: 10*min, groupMin: 1e3, |
158 | 158 | disable: !conf('local', true) |
159 | 159 | }) |
160 | 160 | |
161 | - if(connected === 0) | |
161 | + if(connected < 3) { | |
162 | 162 | connect(peers, ts, 'attempt', exports.isUnattempted, { |
163 | 163 | min: 0, quota: 1, factor: 0, max: 0, groupMin: 0, |
164 | 164 | disable: !conf('global', true) |
165 | 165 | }) |
166 | + } | |
166 | 167 | |
167 | 168 | //quota, groupMin, min, factor, max |
168 | 169 | connect(peers, ts, 'retry', exports.isInactive, { |
169 | 170 | min: 0, |
server-process.js | ||
---|---|---|
@@ -24,6 +24,24 @@ | ||
24 | 24 | } |
25 | 25 | ssbConfig.manifest = context.sbot.getManifest() |
26 | 26 | serveBlobs(context) |
27 | 27 | fs.writeFileSync(Path.join(ssbConfig.path, 'manifest.json'), JSON.stringify(ssbConfig.manifest)) |
28 | + connectToFriendlyPubs(context.sbot) | |
28 | 29 | electron.ipcRenderer.send('server-started', ssbConfig) |
29 | 30 | } |
31 | + | |
32 | +function connectToFriendlyPubs (sbot) { | |
33 | + sbot.gossip.peers((err, peers) => { | |
34 | + if (err) return console.log(err) | |
35 | + sbot.friends.all((err, friends) => { | |
36 | + if (err) return console.log(err) | |
37 | + console.log('Attempting to connect to friendly pubs...') | |
38 | + peers.filter((p) => p.state !== 'connected' && isFriends(friends, sbot.id, p.key)).forEach((peer) => { | |
39 | + sbot.gossip.connect(peer, () => {}) | |
40 | + }) | |
41 | + }) | |
42 | + }) | |
43 | +} | |
44 | + | |
45 | +function isFriends (friends, a, b) { | |
46 | + return friends[a] && friends[b] && friends[a][b] && friends[b][a] | |
47 | +} |
Built with git-ssb-web