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
  • 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

Arguments

  • off is the newly arrived Offchain

  • uri is the URI of the node endpoint. This Uri’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 with ws or wss, respectively (this always works because wss means to make an HTTPS connection and then upgrade to websocket).

  • accs is a map from chain-id to Accounts. 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 corresponding Accounts values.