Add priority to FallbackProviderConfig (#1828)

pull/1839/head
Trevor Porter 2 years ago committed by GitHub
parent 29f0c78f5e
commit 83ec4f0c58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      typescript/infra/src/config/chain.ts

@ -1,3 +1,4 @@
import { FallbackProviderConfig } from '@ethersproject/providers';
import { ethers } from 'ethers'; import { ethers } from 'ethers';
import { StaticCeloJsonRpcProvider } from '@hyperlane-xyz/celo-ethers-provider'; import { StaticCeloJsonRpcProvider } from '@hyperlane-xyz/celo-ethers-provider';
@ -46,7 +47,18 @@ export async function fetchProvider(
} }
case ConnectionType.HttpFallback: { case ConnectionType.HttpFallback: {
return new ethers.providers.FallbackProvider( return new ethers.providers.FallbackProvider(
(rpcData as string[]).map((url) => providerBuilder(url, chainName)), (rpcData as string[]).map((url, index) => {
const fallbackProviderConfig: FallbackProviderConfig = {
provider: providerBuilder(url, chainName),
// Priority is used by the FallbackProvider to determine
// how to order providers using ascending ordering.
// When not specified, all providers have the same priority
// and are ordered randomly for each RPC.
priority: index,
};
console.log('fallbackProviderConfig', fallbackProviderConfig);
return fallbackProviderConfig;
}),
1, // a single provider is "quorum", but failure will cause failover to the next provider 1, // a single provider is "quorum", but failure will cause failover to the next provider
); );
} }

Loading…
Cancel
Save