fix: move to usage of `log`

This commit is contained in:
Franck Royer 2022-06-23 16:38:14 +10:00
parent d609b9c47b
commit 52616fb912
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
1 changed files with 8 additions and 8 deletions

View File

@ -19,7 +19,7 @@ import { StoreCodecs, WakuStore } from "./waku_store";
export const DefaultPingKeepAliveValueSecs = 0; export const DefaultPingKeepAliveValueSecs = 0;
export const DefaultRelayKeepAliveValueSecs = 5 * 60; export const DefaultRelayKeepAliveValueSecs = 5 * 60;
const dbg = debug("waku:waku"); const log = debug("waku:waku");
export enum Protocols { export enum Protocols {
Relay = "relay", Relay = "relay",
@ -316,7 +316,7 @@ export class Waku {
const peers = await this.store.peers(); const peers = await this.store.peers();
if (peers.length) { if (peers.length) {
dbg("Store peer found: ", peers[0].id.toString()); log("Store peer found: ", peers[0].id.toString());
return; return;
} }
@ -324,7 +324,7 @@ export class Waku {
this.libp2p.peerStore.addEventListener("change:protocols", (evt) => { this.libp2p.peerStore.addEventListener("change:protocols", (evt) => {
for (const codec of Object.values(StoreCodecs)) { for (const codec of Object.values(StoreCodecs)) {
if (evt.detail.protocols.includes(codec)) { if (evt.detail.protocols.includes(codec)) {
dbg("Resolving for", codec, evt.detail.protocols); log("Resolving for", codec, evt.detail.protocols);
resolve(); resolve();
} }
} }
@ -339,14 +339,14 @@ export class Waku {
const peers = await this.lightPush.peers(); const peers = await this.lightPush.peers();
if (peers.length) { if (peers.length) {
dbg("Light Push peer found: ", peers[0].id.toString()); log("Light Push peer found: ", peers[0].id.toString());
return; return;
} }
await new Promise<void>((resolve) => { await new Promise<void>((resolve) => {
this.libp2p.peerStore.addEventListener("change:protocols", (evt) => { this.libp2p.peerStore.addEventListener("change:protocols", (evt) => {
if (evt.detail.protocols.includes(LightPushCodec)) { if (evt.detail.protocols.includes(LightPushCodec)) {
dbg("Resolving for", LightPushCodec, evt.detail.protocols); log("Resolving for", LightPushCodec, evt.detail.protocols);
resolve(); resolve();
} }
}); });
@ -360,14 +360,14 @@ export class Waku {
const peers = await this.filter.peers(); const peers = await this.filter.peers();
if (peers.length) { if (peers.length) {
dbg("Filter peer found: ", peers[0].id.toString()); log("Filter peer found: ", peers[0].id.toString());
return; return;
} }
await new Promise<void>((resolve) => { await new Promise<void>((resolve) => {
this.libp2p.peerStore.addEventListener("change:protocols", (evt) => { this.libp2p.peerStore.addEventListener("change:protocols", (evt) => {
if (evt.detail.protocols.includes(FilterCodec)) { if (evt.detail.protocols.includes(FilterCodec)) {
dbg("Resolving for", FilterCodec, evt.detail.protocols); log("Resolving for", FilterCodec, evt.detail.protocols);
resolve(); resolve();
} }
}); });
@ -400,7 +400,7 @@ export class Waku {
if (pingPeriodSecs !== 0) { if (pingPeriodSecs !== 0) {
this.pingKeepAliveTimers[peerIdStr] = setInterval(() => { this.pingKeepAliveTimers[peerIdStr] = setInterval(() => {
this.libp2p.ping(peerId).catch((e) => { this.libp2p.ping(peerId).catch((e) => {
dbg(`Ping failed (${peerIdStr})`, e); log(`Ping failed (${peerIdStr})`, e);
}); });
}, pingPeriodSecs * 1000); }, pingPeriodSecs * 1000);
} }