From ba86b3587baed6699304ac1487de91e453736114 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Thu, 5 Jan 2023 19:44:43 -0500 Subject: [PATCH] *add core.shutdown hook for bootstrap DHT --- src/modules/swarm.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/modules/swarm.ts b/src/modules/swarm.ts index 8ed5f4e..71c754c 100644 --- a/src/modules/swarm.ts +++ b/src/modules/swarm.ts @@ -13,6 +13,7 @@ import sodium from "sodium-universal"; import b4a from "b4a"; import log from "../log.js"; import { getKeyPair } from "../lib/seed.js"; +import { getPluginAPI } from "./plugin"; const LUMEWEB = b4a.from("lumeweb"); export const LUMEWEB_TOPIC_HASH = b4a.allocUnsafe(32); @@ -44,6 +45,10 @@ export async function start() { await node.listen(); node.join(LUMEWEB_TOPIC_HASH); + getPluginAPI().on("core.shutdown", async () => { + return bootstrap.destroy(); + }); + log.info( "Relay Identity is %s", b4a.from(getKeyPair().publicKey).toString("hex")