Use provided API

This commit is contained in:
Franck Royer 2021-05-04 10:23:31 +10:00
parent 689f439948
commit d0020744b4
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
3 changed files with 6 additions and 3 deletions

View File

@ -102,7 +102,7 @@ export default class Waku {
await this.libp2p.dialProtocol(peer, [RelayCodec, StoreCodec]); await this.libp2p.dialProtocol(peer, [RelayCodec, StoreCodec]);
} }
async dialWithMultiAddr(peerId: PeerId, multiaddr: Multiaddr[]) { addPeerToAddressBook(peerId: PeerId, multiaddr: Multiaddr[]) {
this.libp2p.peerStore.addressBook.set(peerId, multiaddr); this.libp2p.peerStore.addressBook.set(peerId, multiaddr);
} }

View File

@ -32,7 +32,10 @@ describe('Waku Relay', () => {
}), }),
]); ]);
await waku1.dialWithMultiAddr(waku2.libp2p.peerId, waku2.libp2p.multiaddrs); await waku1.addPeerToAddressBook(
waku2.libp2p.peerId,
waku2.libp2p.multiaddrs
);
await Promise.all([ await Promise.all([
new Promise((resolve) => new Promise((resolve) =>

View File

@ -42,7 +42,7 @@ function connect(peer: string | undefined, waku: Waku | undefined): string[] {
if (!peerId) { if (!peerId) {
return ['Peer Id needed to dial']; return ['Peer Id needed to dial'];
} }
waku.libp2p.peerStore.addressBook.add(PeerId.createFromB58String(peerId), [ waku.addPeerToAddressBook(PeerId.createFromB58String(peerId), [
peerMultiaddr, peerMultiaddr,
]); ]);
return [ return [