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

Commit

Permalink
Merge pull request #189 from ipfs/feat/peer-book
Browse files Browse the repository at this point in the history
move to peer-book
  • Loading branch information
daviddias committed May 4, 2016
2 parents 5c26fae + ca9e77d commit 036eaf6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions 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
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 036eaf6

Please sign in to comment.