forked from snxraven/p2ns
BREAKING EXPERIMENTAL: Holepunch-native hard migration (RPC core, shared storage, SDK v2)
BREAKING: All nodes must upgrade together. Legacy p2ns.core-request string messages are rejected; invite/consensus control plane uses protomux-rpc (invite.request, invite.ack, invite.relay*, consensus.*). Shared Corestore namespaces are the default for plugin DBs and drives; USE_SHARED_CORESTORE_NAMESPACES=false is debug-only. Admin plugin actions with params are validated before run. EXPERIMENTAL: End-to-end RPC invite path reuses existing handlers via adapters; invite wire still ships on the invite channel. Multi-peer invite/relay integration tests are not in CI yet (core-rpc-smoke only). SDK & channels: - channel-rpc.js, sdk.channels.rpc (register/request/event) - core-rpc.js for p2ns.core; action-params + plugin route validation - sdk.db.getCore/reopen, sdk.state.getPeerChannelSnapshot, sdk.metrics.getHolepunchStats (schema v1) Runtime: - p2ns.js: RPC-first core invite/consensus; Hyperswarm firewall/reconnect - channel-manager: required protomux-rpc per peer - db-shared-namespace-migration; drive-manager shared namespaces - proxy-server: invite.request RPC for joiners Plugins: file.drop, global.profile, peer.directory, domain.consensus, peer.visualize, example.plugin (RPC demo); peer.directory UI polish Also: CI/smoke scripts, diagnostics hardening, plugin config schema validation, admin action param modal, docs/RFCS, package-lock + engines.node >= 18
This commit is contained in:
@@ -15,6 +15,8 @@ const sdk = require('../../includes/plugins/sdk');
|
||||
let updateInterval = null;
|
||||
let lastConsensusStates = new Map(); // Track last known consensus states for change detection
|
||||
let debounceTimer = null;
|
||||
let dnsPassUpdateHandler = null;
|
||||
let coreAppendHandler = null;
|
||||
|
||||
/**
|
||||
* Enrich peer IDs with profile data
|
||||
@@ -486,24 +488,28 @@ async function onInit() {
|
||||
const setupDNSListeners = () => {
|
||||
const dnsPass = sdk.state.dnsPass;
|
||||
const core = sdk.state.core;
|
||||
|
||||
|
||||
if (dnsPass) {
|
||||
// Remove existing listener if any
|
||||
dnsPass.removeAllListeners('update');
|
||||
dnsPass.on('update', () => {
|
||||
if (dnsPassUpdateHandler) {
|
||||
dnsPass.removeListener('update', dnsPassUpdateHandler);
|
||||
}
|
||||
dnsPassUpdateHandler = () => {
|
||||
sdk.log.debug('domain.consensus', 'DNS pass update detected - checking consensus changes');
|
||||
debouncedConsensusCheck();
|
||||
});
|
||||
};
|
||||
dnsPass.on('update', dnsPassUpdateHandler);
|
||||
sdk.log.info('domain.consensus', 'DNS pass update listener registered');
|
||||
}
|
||||
|
||||
if (core) {
|
||||
// Remove existing listener if any
|
||||
core.removeAllListeners('append');
|
||||
core.on('append', () => {
|
||||
if (coreAppendHandler) {
|
||||
core.removeListener('append', coreAppendHandler);
|
||||
}
|
||||
coreAppendHandler = () => {
|
||||
sdk.log.debug('domain.consensus', 'Core append detected - checking consensus changes');
|
||||
debouncedConsensusCheck();
|
||||
});
|
||||
};
|
||||
core.on('append', coreAppendHandler);
|
||||
sdk.log.info('domain.consensus', 'Core append listener registered');
|
||||
}
|
||||
};
|
||||
@@ -567,8 +573,9 @@ async function onShutdown() {
|
||||
// Remove event listeners (safely)
|
||||
try {
|
||||
const dnsPass = sdk.state.dnsPass;
|
||||
if (dnsPass && typeof dnsPass.removeAllListeners === 'function') {
|
||||
dnsPass.removeAllListeners('update');
|
||||
if (dnsPass && dnsPassUpdateHandler) {
|
||||
dnsPass.removeListener('update', dnsPassUpdateHandler);
|
||||
dnsPassUpdateHandler = null;
|
||||
}
|
||||
} catch (err) {
|
||||
sdk.log.debug('domain.consensus', `Error removing DNS pass listeners: ${err.message}`);
|
||||
@@ -576,8 +583,9 @@ async function onShutdown() {
|
||||
|
||||
try {
|
||||
const core = sdk.state.core;
|
||||
if (core && typeof core.removeAllListeners === 'function') {
|
||||
core.removeAllListeners('append');
|
||||
if (core && coreAppendHandler) {
|
||||
core.removeListener('append', coreAppendHandler);
|
||||
coreAppendHandler = null;
|
||||
}
|
||||
} catch (err) {
|
||||
sdk.log.debug('domain.consensus', `Error removing core listeners: ${err.message}`);
|
||||
|
||||
Reference in New Issue
Block a user