git ssb

0+

alanz / patchwork



forked from Matt McKegg / patchwork

Tree: 36cd0eeba48657072d1b4544e72acf7e5eead61f

Files: 36cd0eeba48657072d1b4544e72acf7e5eead61f / lib / persistent-gossip / init.js

847 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.sync) return
20 if(!msg.content.address) return
21 if(ref.isAddress(msg.content.address))
22 gossip.add(msg.content.address, 'pub')
23 })
24 )
25
26 // populate peertable with announcements on the LAN multicast
27 server.on('local', function (_peer) {
28 gossip.add(_peer, 'local')
29 })
30
31}
32

Built with git-ssb-web