0.0.5 • Published 6 years ago

http-list-provider v0.0.5

Weekly downloads
21
License
MIT
Repository
-
Last release
6 years ago

HttpListProvider

This module is a web3 provider that allows using several RPC URLs (instead of just one, like HttpProvider). If one of these URLs is not working, the next one in the list will be used.

Installation

npm install http-list-provider

Usage

Create the provider instance with a list of RPC URLs:

const Web3 = require('web3')
const HttpListProvider = require('http-list-provider')

const provider = new HttpListProvider(['https://mainnet.infura.io', 'http://localhost:8545'])
const web3 = new Web3(provider)

Retrying

http-list-provider uses promise-retry to allow retrying when all the URLs fail. By default, retrying is disabled. You can enable it by doing:

const provider = new HttpListProvider(['https://mainnet.infura.io', 'http://localhost:8545'], {
  retry: {
    retries: 1,
    minTimeout: 10000
  }
})

The object under the retry key will be passed as it is to promise-retry and used for retrying.

Testing

To run the tests, start ganache-cli in the default (8545) port and then run npm test.

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago