Function cubist_proxy::pipeline::ava
source · pub fn ava(
off: Offchain,
uri: Uri,
proxies: Arc<HashMap<String, Arc<CredProxy>>>
) -> JoinHandle<Result<(), FatalErr>>
Expand description
Handle either HTTPS or WebSocket connection for Avalanche EVM chains
Given an Offchain, we determine how to handle it as follows:
-
HTTP connection: we need to consider requests one by one because an HTTP Offchain can produce requests to multiple paths. For each request, we examine the path and dispatch accordingly:
- if we have creds for this chain-id, handle it using long-lived
eth_creds
instances. - otherwise, just pass through the request to the server specified by
uri
- if we have creds for this chain-id, handle it using long-lived
-
Websocket connection to path /ext/bc/<chain-id>/ws
- if we have creds for this chain-id, handle it using
eth_creds
- otherwise, just pass through the request to the server specified by
uri
- if we have creds for this chain-id, handle it using
Arguments
-
off
is the newly arrivedOffchain
-
uri
is the URI of the node endpoint. ThisUri
’s path and query are ignored, since they are replaced with the proper path per-query. Note also that this Uri should have an HTTP or HTTPS scheme; when a websocket is needed, the scheme will be replaced withws
orwss
, respectively (this always works becausewss
means to make an HTTPS connection and then upgrade to websocket). -
accs
is a map from chain-id toAccounts
. For example, if you have credentials for the C-chain and a chain with id “foobar”, your map should contain keys “C” and “foobar” with correspondingAccounts
values.