*add getActivePeers api method

This commit is contained in:
Derrick Hammer 2023-03-30 21:06:04 -04:00
parent cad93cbb21
commit fd2d66d2c4
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 7 additions and 0 deletions

View File

@ -68,6 +68,7 @@ addHandler("stat", handleStat);
addHandler("ls", handleLs, { receiveUpdates: true });
addHandler("cat", handleCat, { receiveUpdates: true });
addHandler("ipnsResolve", handleIpnsResolve);
addHandler("getActivePeers", handleGetActivePeers);
async function handlePresentSeed() {
swarm = createClient();
@ -329,6 +330,12 @@ async function handleIpnsResolve(aq: ActiveQuery) {
}
}
async function handleGetActivePeers(aq: ActiveQuery) {
await ready();
aq.respond(PeerManager.instance.ipfs.libp2p.getPeers());
}
async function ready() {
await moduleDefer.promise;
await PeerManager.instance.ipfsReady;