mirror of https://github.com/waku-org/js-waku.git
parent
50fb533e44
commit
75f605a676
|
@ -108,13 +108,15 @@ export class WakuStore {
|
||||||
let peer;
|
let peer;
|
||||||
if (opts.peerId) {
|
if (opts.peerId) {
|
||||||
peer = this.libp2p.peerStore.get(opts.peerId);
|
peer = this.libp2p.peerStore.get(opts.peerId);
|
||||||
if (!peer) throw 'Peer is unknown';
|
if (!peer)
|
||||||
|
throw `Failed to retrieve connection details for provided peer in peer store: ${opts.peerId.toB58String()}`;
|
||||||
} else {
|
} else {
|
||||||
peer = this.randomPeer;
|
peer = this.randomPeer;
|
||||||
|
if (!peer)
|
||||||
|
throw 'Failed to find known peer that registers waku store protocol';
|
||||||
}
|
}
|
||||||
if (!peer) throw 'No peer available';
|
|
||||||
if (!peer.protocols.includes(StoreCodec))
|
if (!peer.protocols.includes(StoreCodec))
|
||||||
throw 'Peer does not register waku store protocol';
|
throw `Peer does not register waku store protocol: ${peer.id.toB58String()}`;
|
||||||
const connection = this.libp2p.connectionManager.get(peer.id);
|
const connection = this.libp2p.connectionManager.get(peer.id);
|
||||||
if (!connection) throw 'Failed to get a connection to the peer';
|
if (!connection) throw 'Failed to get a connection to the peer';
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue