Skip to content

Commit

Permalink
Revert "feat(light client): Use wss boot nodes only (#2345)"
Browse files Browse the repository at this point in the history
This reverts commit 02e778d.
  • Loading branch information
rossbulat committed Dec 1, 2024
1 parent 02e778d commit ed4e179
Showing 1 changed file with 3 additions and 27 deletions.
30 changes: 3 additions & 27 deletions packages/app/src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,32 +111,16 @@ export class Api {
const smMetadata = getLightClientMetadata(this.#chainType, this.network);
const { chainSpec: relayChainSpec } = await smMetadata.relay.fn();

// Filter non-encrypted boot nodes in production.
const wssRelayChainSpec =
import.meta.env.MODE === 'development'
? relayChainSpec
: this.wssBootNodesOnly(relayChainSpec);

let chain;
if (this.#chainType === 'relay') {
chain = smoldot.addChain({
chainSpec: wssRelayChainSpec,
});
chain = smoldot.addChain({ chainSpec: relayChainSpec });
this.#apiClient = createClient(getSmProvider(chain));
} else {
const { chainSpec: paraChainSpec } = await smMetadata!.para!.fn();
// Filter non-encrypted boot nodes in production.
const wssParaChainSpec =
import.meta.env.MODE === 'development'
? paraChainSpec
: this.wssBootNodesOnly(paraChainSpec);

chain = smoldot.addChain({
chainSpec: this.wssBootNodesOnly(wssParaChainSpec),
chainSpec: paraChainSpec,
potentialRelayChains: [
await smoldot.addChain({
chainSpec: wssRelayChainSpec,
}),
await smoldot.addChain({ chainSpec: relayChainSpec }),
],
});
this.#apiClient = createClient(getSmProvider(chain));
Expand Down Expand Up @@ -277,12 +261,4 @@ export class Api {
this.dispatchEvent(this.ensureEventStatus('disconnected'));
}
}

wssBootNodesOnly(spec: string) {
const filtered = Object.assign({}, JSON.parse(spec));
filtered.bootNodes = filtered.bootNodes.filter((node: string) =>
/\/wss\//.test(node)
);
return JSON.stringify(filtered);
}
}

0 comments on commit ed4e179

Please sign in to comment.