Files: 9216a0ee5a7da1602222d794ef538ca059e1face / lib / persistent-gossip / init.js
847 bytesRaw
1 | var isArray = Array.isArray |
2 | var pull = require('pull-stream') |
3 | var ref = require('ssb-ref') |
4 | |
5 | module.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