Compare commits

..

No commits in common. "v0.1.0-develop.6" and "v0.1.0-develop.5" have entirely different histories.

4 changed files with 3 additions and 66 deletions

View File

@ -1,10 +1,3 @@
# [0.1.0-develop.6](https://git.lumeweb.com/LumeWeb/kernel-ipfs/compare/v0.1.0-develop.5...v0.1.0-develop.6) (2023-07-23)
### Features
* add status api ([16dcaaf](https://git.lumeweb.com/LumeWeb/kernel-ipfs/commit/16dcaafd781ee3957a489c73b8027b2eabca648f))
# [0.1.0-develop.5](https://git.lumeweb.com/LumeWeb/kernel-ipfs/compare/v0.1.0-develop.4...v0.1.0-develop.5) (2023-07-23)
# [0.1.0-develop.4](https://git.lumeweb.com/LumeWeb/kernel-ipfs/compare/v0.1.0-develop.3...v0.1.0-develop.4) (2023-07-23)

4
npm-shrinkwrap.json generated
View File

@ -1,12 +1,12 @@
{
"name": "@lumeweb/kernel-ipfs",
"version": "0.1.0-develop.6",
"version": "0.1.0-develop.5",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@lumeweb/kernel-ipfs",
"version": "0.1.0-develop.6",
"version": "0.1.0-develop.5",
"hasInstallScript": true,
"dependencies": {
"@helia/ipns": "^1.1.3",

View File

@ -1,6 +1,6 @@
{
"name": "@lumeweb/kernel-ipfs",
"version": "0.1.0-develop.6",
"version": "0.1.0-develop.5",
"type": "module",
"readme": "ERROR: No README data found!",
"repository": {

View File

@ -43,7 +43,6 @@ onmessage = handleMessage;
const moduleDefer = defer();
let activeIpfsPeersDefer = defer();
let networkPeersAvailable = defer();
let networkReady = true;
const networkRegistry = createNetworkRegistryClient();
let swarm;
@ -59,7 +58,6 @@ BigInt.prototype.toJSON = function () {
addHandler("presentKey", handlePresentKey);
addHandler("register", handleRegister);
addHandler("status", handleStatus, { receiveUpdates: true });
addHandler("ready", handleReady);
addHandler("stat", handleStat);
addHandler("ls", handleLs, { receiveUpdates: true });
@ -96,7 +94,6 @@ async function handlePresentKey() {
if (!ipfs.libp2p.isStarted()) {
await ipfs.start();
networkPeersAvailable.resolve();
networkReady = true;
}
});
@ -298,56 +295,3 @@ async function handleRegister(aq: ActiveQuery) {
aq.respond();
}
async function handleStatus(aq: ActiveQuery) {
function sendUpdate() {
aq.sendUpdate({
peers: netPeers,
ready: netPeers > 0,
});
}
let netPeers = 0;
if (!networkReady) {
sendUpdate();
await ready();
getPeers();
}
function getPeers() {
netPeers = ipfs.libp2p.getPeers().length;
}
function peersListener() {
getPeers();
sendUpdate();
}
const peerEvents = ["connection:prune", "peer:connect", "peer:disconnect"];
peerEvents.forEach((ev) => {
// @ts-ignore
ipfs.libp2p.components.connectionManager.events.addEventListener(
ev,
peersListener,
);
});
// @ts-ignore
ipfs.libp2p.components.connectionManager.events.addEventListener(
"peer:disconnect",
peersListener,
);
aq.setReceiveUpdate?.(() => {
peerEvents.forEach((ev) => {
// @ts-ignore
ipfs.libp2p.components.connectionManager.events.removeEventListener(
ev,
peersListener,
);
});
aq.respond();
});
sendUpdate();
}