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 74
74
"lodash.get" : " ^4.2.1" ,
75
75
"lodash.set" : " ^4.0.0" ,
76
76
"multiaddr" : " ^1.3.0" ,
77
+ "peer-book" : " 0.1.0" ,
77
78
"peer-id" : " ^0.6.6" ,
78
79
"peer-info" : " ^0.6.2" ,
79
80
"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
13
13
const libp2p = require ( 'libp2p-ipfs' )
14
14
const init = require ( './init' )
15
15
const IPFSRepo = require ( 'ipfs-repo' )
16
+ const PeerBook = require ( 'peer-book' )
16
17
17
18
exports = module . exports = IPFS
18
19
@@ -29,7 +30,7 @@ function IPFS (repo) {
29
30
const dagS = new DAGService ( blockS )
30
31
var peerInfo
31
32
var libp2pNode
32
- var peerInfoBook = { }
33
+ const peerInfoBook = new PeerBook ( )
33
34
34
35
this . load = ( callback ) => {
35
36
repo . exists ( ( err , exists ) => {
@@ -339,7 +340,7 @@ function IPFS (repo) {
339
340
return callback ( OFFLINE_ERROR )
340
341
}
341
342
342
- callback ( null , peerInfoBook )
343
+ callback ( null , peerInfoBook . getAll ( ) )
343
344
} ,
344
345
// all the addrs we know
345
346
addrs : ( callback ) => {
@@ -371,7 +372,7 @@ function IPFS (repo) {
371
372
ma = ma . toString ( ) . replace ( / \/ i p f s \/ ( .* ) / , '' ) // FIXME remove this when multiaddr supports ipfs
372
373
373
374
peer . multiaddr . add ( multiaddr ( ma ) )
374
- peerInfoBook [ peer . id . toB58String ( ) ] = peer
375
+ peerInfoBook . put ( peer )
375
376
376
377
libp2pNode . swarm . dial ( peer , ( err ) => {
377
378
callback ( err , id )
You can’t perform that action at this time.
0 commit comments