Skip to content

Commit

Permalink
Merge pull request #604 from ssbc/add-friends
Browse files Browse the repository at this point in the history
Add friends config option to connect to peers marked as friends
  • Loading branch information
arj03 committed Dec 23, 2018
2 parents 7755ec8 + a60587a commit f355514
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions plugins/gossip/schedule.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,11 @@ function (gossip, config, server) {

var connectedFriends = peers.filter(and(isConnect, isFriend)).length

if(conf('friends', true))
connect(peers, ts, 'friends', isFriend, {
quota: 3, factor: 2e3, max: 10*min, groupMin: 1e3,
})

if(conf('seed', true))
connect(peers, ts, 'seeds', isSeed, {
quota: 3, factor: 2e3, max: 10*min, groupMin: 1e3,
Expand Down Expand Up @@ -231,20 +236,20 @@ function (gossip, config, server) {
if(timer.unref) timer.unref()
}

pull(
gossip.changes(),
pull.drain(function (ev) {
if(ev.type == 'disconnect')
connections()
}, function () {
console.warn('[gossip/dc] warning: this can happen if the database closes', arguments)
})
)
pull(
gossip.changes(),
pull.drain(function (ev) {
if(ev.type == 'disconnect')
connections()
}, function () {
console.warn('[gossip/dc] warning: this can happen if the database closes', arguments)
})
)

var int = setInterval(connections, 2e3)
if(int.unref) int.unref()
var int = setInterval(connections, 2e3)
if(int.unref) int.unref()

connections()
connections()

return function onClose () {
closed = true
Expand All @@ -260,6 +265,3 @@ exports.isLocal = isLocal
exports.isFriend = isFriend
exports.isConnectedOrConnecting = isConnect
exports.select = select



0 comments on commit f355514

Please sign in to comment.