Improve P2P stats peer locations and Kubo display (#1139)

* feat(p2p stats): plot peers by ip location

* fix(p2p stats): show own node map marker

* feat(p2p stats): support full node peers

* fix(p2p stats): clean up kubo stats

* fix(p2p stats): address review feedback
This commit is contained in:
Tommaso Casaburi
2026-05-24 17:32:05 +07:00
committed by GitHub
parent a6a1320381
commit 804c14fc35
9 changed files with 1051 additions and 81 deletions
+9 -2
View File
@@ -49,11 +49,11 @@ describe('p2p-runtime', () => {
expect(getP2PRuntimeMode({ pkc: { clients: { libp2pJsClients: { libp2pjs: {} } } } }, browserWindow)).toBe('browser-libp2p');
});
it('detects electron Kubo RPC accounts only in electron runtime', () => {
it('detects full-node RPC accounts in browser and electron runtimes', () => {
const account = { pkcOptions: { pkcRpcClientsOptions: ['ws://localhost:9138'] } };
expect(getP2PRuntimeMode(account, electronWindow)).toBe('electron-kubo-rpc');
expect(getP2PRuntimeMode(account, browserWindow)).toBeNull();
expect(getP2PRuntimeMode(account, browserWindow)).toBe('full-node-rpc');
});
it('shows p2p settings in browsers when pure p2p is enabled by default', () => {
@@ -70,6 +70,13 @@ describe('p2p-runtime', () => {
expect(isBrowserPureP2PEnabled(gatewayAccount, p2pBrowserWindowWithDisabledPureP2P)).toBe(false);
});
it('still shows browser full-node RPC stats when browser pure p2p was toggled off', () => {
const account = { pkcOptions: { pkcRpcClientsOptions: ['ws://node.example'] } };
expect(isBrowserPureP2PEnabled(account, browserWindowWithDisabledPureP2P)).toBe(false);
expect(shouldShowP2PSettingsSection(account, browserWindowWithDisabledPureP2P)).toBe(true);
});
it('builds browser p2p and gateway account options without a direct pkc-js import', () => {
const account = {
pkcOptions: {