Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
move to peer-book
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddias committed May 4, 2016
1 parent a3f061a commit ca9e77d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"lodash.get": "^4.2.1",
"lodash.set": "^4.0.0",
"multiaddr": "^1.3.0",
"peer-book": "0.1.0",
"peer-id": "^0.6.6",
"peer-info": "^0.6.2",
"ronin": "^0.3.11",
Expand Down Expand Up @@ -111,4 +112,4 @@
"kumavis <[email protected]>",
"nginnever <[email protected]>"
]
}
}
7 changes: 4 additions & 3 deletions src/core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const importer = require('ipfs-data-importing').import
const libp2p = require('libp2p-ipfs')
const init = require('./init')
const IPFSRepo = require('ipfs-repo')
const PeerBook = require('peer-book')

exports = module.exports = IPFS

Expand All @@ -29,7 +30,7 @@ function IPFS (repo) {
const dagS = new DAGService(blockS)
var peerInfo
var libp2pNode
var peerInfoBook = {}
const peerInfoBook = new PeerBook()

this.load = (callback) => {
repo.exists((err, exists) => {
Expand Down Expand Up @@ -339,7 +340,7 @@ function IPFS (repo) {
return callback(OFFLINE_ERROR)
}

callback(null, peerInfoBook)
callback(null, peerInfoBook.getAll())
},
// all the addrs we know
addrs: (callback) => {
Expand Down Expand Up @@ -371,7 +372,7 @@ function IPFS (repo) {
ma = ma.toString().replace(/\/ipfs\/(.*)/, '') // FIXME remove this when multiaddr supports ipfs

peer.multiaddr.add(multiaddr(ma))
peerInfoBook[peer.id.toB58String()] = peer
peerInfoBook.put(peer)

libp2pNode.swarm.dial(peer, (err) => {
callback(err, id)
Expand Down

0 comments on commit ca9e77d

Please sign in to comment.