Skip to content

Commit

Permalink
chore: do not use peerstore.put on get-peer-info
Browse files Browse the repository at this point in the history
  • Loading branch information
vasco-santos committed Apr 1, 2020
1 parent d3e4ad2 commit c4df833
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/get-peer-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ function getPeerInfo (peer, peerStore) {

addr && peer.multiaddrs.add(addr)

return peerStore ? peerStore.put(peer, { replace: false }) : peer
if (peerStore) {
peerStore.addressBook.set(peer.id, peer.multiaddrs.toArray(), { replace: false })
peerStore.protoBook.set(peer.id, Array.from(peer.protocols), { replace: false })
}

return peer
}

/**
Expand Down
2 changes: 1 addition & 1 deletion test/dialing/direct.node.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ describe('Dialing (direct, TCP)', () => {
const peerId = await PeerId.createFromJSON(Peers[0])
const peerInfo = new PeerInfo(peerId)
peerInfo.multiaddrs.add(remoteAddr)
peerStore.put(peerInfo)
peerStore.addressBook.set(peerInfo.id, peerInfo.multiaddrs.toArray())

const connection = await dialer.connectToPeer(peerInfo)
expect(connection).to.exist()
Expand Down

0 comments on commit c4df833

Please sign in to comment.