*Remove self from peers list

This commit is contained in:
Derrick Hammer 2022-12-05 15:38:58 -05:00
parent 9e480f1cfb
commit 8ea5a38b83
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 10 additions and 1 deletions

View File

@ -127,7 +127,16 @@ const plugin: Plugin = {
api.registerMethod("get_peers", { api.registerMethod("get_peers", {
cacheable: false, cacheable: false,
async handler(): Promise<string[]> { async handler(): Promise<string[]> {
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", { api.registerMethod("get_direct_peers", {