git ssb

4+

Dominic / scuttlebot



Tree: 682c3a5400995ac0d881d88c82a8647730578ba2

Files: 682c3a5400995ac0d881d88c82a8647730578ba2 / plugins / gossip / init.js

824 bytesRaw
1var isArray = Array.isArray
2var pull = require('pull-stream')
3var ref = require('ssb-ref')
4
5module.exports = function (gossip, config, server) {
6
7 // populate peertable with configured seeds (mainly used in testing)
8 var seeds = config.seeds
9
10 ;(isArray(seeds) ? seeds : [seeds]).filter(Boolean)
11 .forEach(function (addr) { gossip.add(addr, 'seed') })
12
13 // populate peertable with pub announcements on the feed
14 pull(
15 server.messagesByType({
16 type: 'pub', live: true, keys: false
17 }),
18 pull.drain(function (msg) {
19 if(!msg.content.address) return
20 if(ref.isAddress(msg.content.address))
21 gossip.add(msg.content.address, 'pub')
22 })
23 )
24
25 // populate peertable with announcements on the LAN multicast
26 server.on('local', function (_peer) {
27 gossip.add(_peer, 'local')
28 })
29
30}
31
32
33
34

Built with git-ssb-web