add peer cache support

This commit is contained in:
Sasha 2025-09-11 22:34:22 +02:00
parent 8d773c4620
commit 50c7cd16d1
No known key found for this signature in database

View File

@ -1,5 +1,5 @@
import { PeerId } from "@libp2p/interface";
import { Libp2p } from "@waku/interfaces";
import { Libp2p, Tags } from "@waku/interfaces";
import { Logger } from "@waku/utils";
type BootstrapTriggerConstructorOptions = {
@ -73,10 +73,10 @@ export class BootstrapTrigger implements IBootstrapTrigger {
const bootstrapComponents = Object.values(this.libp2p.components.components)
.filter((c) => !!c)
.filter(
(c: unknown) =>
(c as { [Symbol.toStringTag]: string })[Symbol.toStringTag] ===
"@waku/bootstrap"
.filter((c: unknown) =>
[`@waku/${Tags.BOOTSTRAP}`, `@waku/${Tags.PEER_CACHE}`].includes(
(c as { [Symbol.toStringTag]: string })?.[Symbol.toStringTag]
)
);
if (bootstrapComponents.length === 0) {
@ -90,7 +90,8 @@ export class BootstrapTrigger implements IBootstrapTrigger {
bootstrapComponents.forEach((component) => {
try {
(component as { start: () => void }).start();
(component as { stop: () => void })?.stop?.();
(component as { start: () => void })?.start?.();
log.info("Successfully started bootstrap component");
} catch (error) {
log.error("Failed to start bootstrap component", error);