feat!: Do not start libp2p automatically with createWaku

Reduce the number of actions `createWaku` does.
This commit is contained in:
Franck Royer 2022-07-27 12:54:02 +10:00 committed by fryorcraken.eth
parent b7b6a11f43
commit 98d14e08b0
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
2 changed files with 6 additions and 2 deletions

View File

@ -44,6 +44,8 @@ export async function waitForRemotePeer(
): Promise<void> {
protocols = protocols ?? [Protocols.Relay];
if (!waku.isStarted()) return Promise.reject("Waku node is not started");
const promises = [];
if (protocols.includes(Protocols.Relay)) {

View File

@ -107,8 +107,6 @@ export async function createWaku(options?: CreateOptions): Promise<Waku> {
const wakuLightPush = new WakuLightPush(libp2p, options);
const wakuFilter = new WakuFilter(libp2p, options);
await libp2p.start();
return new Waku(options ?? {}, libp2p, wakuStore, wakuLightPush, wakuFilter);
}
@ -233,6 +231,10 @@ export class Waku {
await this.libp2p.stop();
}
isStarted(): boolean {
return this.libp2p.isStarted();
}
/**
* Register a decryption key to attempt decryption of messages received via
* [[WakuRelay]] and [[WakuStore]]. This can either be a private key for