This repository was archived by the owner on Feb 12, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +5
-3
lines changed
Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Original file line number Diff line number Diff line change 7474 "lodash.get" : " ^4.2.1" ,
7575 "lodash.set" : " ^4.0.0" ,
7676 "multiaddr" : " ^1.3.0" ,
77+ "peer-book" : " 0.1.0" ,
7778 "peer-id" : " ^0.6.6" ,
7879 "peer-info" : " ^0.6.2" ,
7980 "ronin" : " ^0.3.11" ,
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ const importer = require('ipfs-data-importing').import
1313const libp2p = require ( 'libp2p-ipfs' )
1414const init = require ( './init' )
1515const IPFSRepo = require ( 'ipfs-repo' )
16+ const PeerBook = require ( 'peer-book' )
1617
1718exports = module . exports = IPFS
1819
@@ -29,7 +30,7 @@ function IPFS (repo) {
2930 const dagS = new DAGService ( blockS )
3031 var peerInfo
3132 var libp2pNode
32- var peerInfoBook = { }
33+ const peerInfoBook = new PeerBook ( )
3334
3435 this . load = ( callback ) => {
3536 repo . exists ( ( err , exists ) => {
@@ -339,7 +340,7 @@ function IPFS (repo) {
339340 return callback ( OFFLINE_ERROR )
340341 }
341342
342- callback ( null , peerInfoBook )
343+ callback ( null , peerInfoBook . getAll ( ) )
343344 } ,
344345 // all the addrs we know
345346 addrs : ( callback ) => {
@@ -371,7 +372,7 @@ function IPFS (repo) {
371372 ma = ma . toString ( ) . replace ( / \/ i p f s \/ ( .* ) / , '' ) // FIXME remove this when multiaddr supports ipfs
372373
373374 peer . multiaddr . add ( multiaddr ( ma ) )
374- peerInfoBook [ peer . id . toB58String ( ) ] = peer
375+ peerInfoBook . put ( peer )
375376
376377 libp2pNode . swarm . dial ( peer , ( err ) => {
377378 callback ( err , id )
You can’t perform that action at this time.
0 commit comments