From 8ea5a38b830ad3c1ede56de67291cd4cf78d16af Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Mon, 5 Dec 2022 15:38:58 -0500 Subject: [PATCH] *Remove self from peers list --- src/modules/plugins/rpc.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/modules/plugins/rpc.ts b/src/modules/plugins/rpc.ts index a818e18..4c13e85 100644 --- a/src/modules/plugins/rpc.ts +++ b/src/modules/plugins/rpc.ts @@ -127,7 +127,16 @@ const plugin: Plugin = { api.registerMethod("get_peers", { cacheable: false, async handler(): Promise { - return [...getRpcServer().cache.dhtCache.online]; + const pubkey = b4a + .from(getRpcServer().cache.swarm.keyPair.publicKey) + .toString("hex"); + + const online = getRpcServer().cache.dhtCache.online; + if (online.has(pubkey)) { + online.delete(pubkey); + } + + return [...online]; }, }); api.registerMethod("get_direct_peers", {