fix: defaults to mounted protocol when dialing

This commit is contained in:
fryorcraken.eth 2022-11-15 21:23:27 +11:00
parent 1b85373472
commit 12fa89c930
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
1 changed files with 10 additions and 3 deletions

View File

@ -13,8 +13,8 @@ import { FilterCodec, WakuFilter } from "./waku_filter";
import { LightPushCodec, WakuLightPush } from "./waku_light_push"; import { LightPushCodec, WakuLightPush } from "./waku_light_push";
import { EncoderV0 } from "./waku_message/version_0"; import { EncoderV0 } from "./waku_message/version_0";
import { WakuRelay } from "./waku_relay"; import { WakuRelay } from "./waku_relay";
import { RelayCodecs, RelayPingContentTopic } from "./waku_relay/constants";
import * as relayConstants from "./waku_relay/constants"; import * as relayConstants from "./waku_relay/constants";
import { RelayCodecs, RelayPingContentTopic } from "./waku_relay/constants";
import { StoreCodec, WakuStore } from "./waku_store"; import { StoreCodec, WakuStore } from "./waku_store";
export const DefaultPingKeepAliveValueSecs = 0; export const DefaultPingKeepAliveValueSecs = 0;
@ -109,13 +109,20 @@ export class WakuNode implements Waku {
* Dials to the provided peer. * Dials to the provided peer.
* *
* @param peer The peer to dial * @param peer The peer to dial
* @param protocols Waku protocols we expect from the peer; Default to Relay * @param protocols Waku protocols we expect from the peer; Defaults to mounted protocols
*/ */
async dial( async dial(
peer: PeerId | Multiaddr, peer: PeerId | Multiaddr,
protocols?: Protocols[] protocols?: Protocols[]
): Promise<Stream> { ): Promise<Stream> {
const _protocols = protocols ?? [Protocols.Relay]; const _protocols = protocols ?? [];
if (typeof protocols === "undefined") {
this.relay && _protocols.push(Protocols.Relay);
this.store && _protocols.push(Protocols.Store);
this.filter && _protocols.push(Protocols.Filter);
this.lightPush && _protocols.push(Protocols.LightPush);
}
const codecs: string[] = []; const codecs: string[] = [];
if (_protocols.includes(Protocols.Relay)) { if (_protocols.includes(Protocols.Relay)) {