fremantle-industries / slurp

An EVM block ingestion toolkit for Elixir
MIT License
28 stars 3 forks source link

Add websocket new head subscriptions that fall back to polling on error #11

Open rupurt opened 3 years ago

rupurt commented 3 years ago

Given a blockchain adapter When it receives N websocket disconnections for new head subscriptions in a period P Then it should try the alternate websocket RPC providers or fallback to polling according to the configured strategy

The venue configuration DSL will need an additional option

config :slurp,
  blockchains: %{
    "ethereum-mainnet" => %{
      start_on_boot: false,
      name: "Ethereum Mainnet",
      adapter: Slurp.Adapters.Evm,
      network_id: 1,
      chain_id: 1,
      chain: "ETH",
      testnet: false,
      timeout: 5000,
      new_head_initial_history: 128,
      poll_interval_ms: 2_500,
      rpc: [
        "wss://main-light.eth.linkpool.io/ws"
      ]
      # Select strategy websocket connection disconnect
      websocket_fallback_strategy: {Slurp.RpcStrategies.WebsocketFallback, :next, [[count: 5, per: 1, unit: :minute]]},
    }
  }
rupurt commented 3 years ago

@AwaitFuture ^