Open wottpal opened 1 year ago
+1
Not sure how good this applies here but a nice detail pjs apps does, is randomizing rpc endpoints. It's a nice detail to prevent overloading a single rpc and centralization through a single rpc provider.
https://github.com/scio-labs/use-inkathon/assets/839848/e17b4e7e-20bc-4e2a-81a0-13426d9d7cf9
WsProvider
accepts a string array of endpoints in the constructor as well as autoConnectMs: number
The only problem I see with passing an array of strings to the WsProvider
is that this would still not accompany for a given mixed set of https://
& wss://
endpoints. But I would be fine with having this implemented (after filtering the strings) as suggested … but have also never tried this approach and don't know how well this is handled by polkadot.js internally. Anyone? cc @peetzweg
When I had this issue described in #73 I've searched the parameters and docs of pjs but I wasn't able to find a feature like this. I know that pjs tries to reconnect if the connection drops or attempts to initialize it again, however it does not offer a way to specify more than a single provider.
Currently, the RPC selection is too simple. It picks the first item in the
rpcUrls
array of aSubstrateChain
(see https://github.com/scio-labs/use-inkathon/blob/main/src/provider.tsx#L82) and creates aWsProvider
object (which even fails if the provided url is not a websocket).