atomicDEX-API
atomicDEX-API copied to clipboard
Share EVM Web3 Instances for Platform Coin and Tokens to Reduce Open Websocket Connections
Needed after this PR https://github.com/KomodoPlatform/komodo-defi-framework/pull/2058 is merged ref. https://github.com/KomodoPlatform/komodo-defi-framework/pull/2058#discussion_r1499053370
I don't think we keep different open connections here.
We do clone the transport here: https://github.com/KomodoPlatform/komodo-defi-framework/blob/2e21532a3012ad040d7da896559bfe63f5d9382f/mm2src/coins/eth/v2_activation.rs#L376
Which is defined like this: https://github.com/KomodoPlatform/komodo-defi-framework/blob/2e21532a3012ad040d7da896559bfe63f5d9382f/mm2src/coins/eth/web3_transport/websocket_transport.rs#L43-L58
Nearly everything is shared/Arc<
ed, only WebsocketTransportNode
& GuiAuthValidationGenerator
are cloned.
The websocket corresponding to the instance is stored (and dropped) in WebsocketTransport::start_connection_loop
:
https://github.com/KomodoPlatform/komodo-defi-framework/blob/2e21532a3012ad040d7da896559bfe63f5d9382f/mm2src/coins/eth/web3_transport/websocket_transport.rs#L260-L275
Which is guarded not to run twice by let _guard = self.connection_guard.lock().await;
and connection_guard
is also shared on cloning, so we would never open two connections for different tickers.
Note
Don't forget to still PR this if this issue is closed without a PR.