feat: address and proto books (#590)

* feat: address and proto books

* chore: apply suggestions from code review

Co-Authored-By: Jacob Heun <jacobheun@gmail.com>

* chore: minor fixes and initial tests added

* chore: integrate new peer-store with code using adapters for other modules

* chore: do not use peerstore.put on get-peer-info

* chore: apply suggestions from code review

Co-Authored-By: Jacob Heun <jacobheun@gmail.com>

* chore: add new peer store tests

* chore: apply suggestions from code review

Co-Authored-By: Jacob Heun <jacobheun@gmail.com>

Co-authored-by: Jacob Heun <jacobheun@gmail.com>
This commit is contained in:
Vasco Santos
2020-04-09 16:07:18 +02:00
parent 97455957ac
commit a08a725123
23 changed files with 2019 additions and 480 deletions

View File

@ -44,7 +44,8 @@ describe('DHT subsystem operates correctly', () => {
remoteLibp2p.start()
])
remAddr = libp2p.peerStore.multiaddrsForPeer(remotePeerInfo)[0]
libp2p.peerStore.addressBook.set(remotePeerInfo.id, [remoteListenAddr])
remAddr = libp2p.peerStore.addressBook.getMultiaddrsForPeer(remotePeerInfo.id)[0]
})
afterEach(() => Promise.all([
@ -68,7 +69,6 @@ describe('DHT subsystem operates correctly', () => {
const value = Buffer.from('world')
await libp2p.dialProtocol(remAddr, subsystemMulticodecs)
await Promise.all([
pWaitFor(() => libp2p._dht.routingTable.size === 1),
pWaitFor(() => remoteLibp2p._dht.routingTable.size === 1)
@ -99,7 +99,8 @@ describe('DHT subsystem operates correctly', () => {
await libp2p.start()
await remoteLibp2p.start()
remAddr = libp2p.peerStore.multiaddrsForPeer(remotePeerInfo)[0]
libp2p.peerStore.addressBook.set(remotePeerInfo.id, [remoteListenAddr])
remAddr = libp2p.peerStore.addressBook.getMultiaddrsForPeer(remotePeerInfo.id)[0]
})
afterEach(() => Promise.all([