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:
@@ -773,8 +773,10 @@ async function setupP2NS() {
|
||||
logDebug('Swarm', 'Skipping p2ns-topic Corestore replication (Autopass handles dnsPass sync)');
|
||||
|
||||
const mux = Protomux.from(conn);
|
||||
const ProtomuxRPC = require('protomux-rpc');
|
||||
const inviteChannel = mux.createChannel({ protocol: 'p2ns.core-invite' });
|
||||
const requestChannel = mux.createChannel({ protocol: 'p2ns.core-request' });
|
||||
const requestRpc = new ProtomuxRPC(mux, { protocol: 'p2ns.core-request-rpc' });
|
||||
|
||||
const inviteMessage = inviteChannel.addMessage({
|
||||
encoding: c.string,
|
||||
@@ -806,16 +808,25 @@ async function setupP2NS() {
|
||||
|
||||
inviteChannel.open();
|
||||
requestChannel.open();
|
||||
state.peerChannels.set(peerId, { inviteChannel, requestChannel, inviteMessage, requestMessage });
|
||||
state.peerChannels.set(peerId, { inviteChannel, requestChannel, inviteMessage, requestMessage, requestRpc });
|
||||
|
||||
if (!isMaster) {
|
||||
const maxRetries = 10;
|
||||
let retryCount = 0;
|
||||
const retryInterval = 5000;
|
||||
const jsonEncoding = {
|
||||
preencode(state, value) { c.string.preencode(state, JSON.stringify(value ?? null)); },
|
||||
encode(state, value) { c.string.encode(state, JSON.stringify(value ?? null)); },
|
||||
decode(state) { return JSON.parse(c.string.decode(state)); }
|
||||
};
|
||||
const sendInviteRequest = () => {
|
||||
if (dnsPass || retryCount >= maxRetries || conn.destroyed) return;
|
||||
retryCount++;
|
||||
requestMessage.send('request_invite');
|
||||
try {
|
||||
requestRpc.event('invite.request', {}, { requestEncoding: jsonEncoding });
|
||||
} catch (err) {
|
||||
logDebug('Swarm', `RPC invite.request failed: ${err.message}`);
|
||||
}
|
||||
setTimeout(sendInviteRequest, retryInterval);
|
||||
};
|
||||
sendInviteRequest();
|
||||
|
||||
Reference in New Issue
Block a user