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

move to peer-book #189

Merged
merged 1 commit into from
May 4, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 <kumavis@users.noreply.github.com>",
"nginnever <ginneversource@gmail.com>"
]
}
}
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