reconnect for ws
This commit is contained in:
parent
eb6b1fe0d1
commit
cea18e6a5f
@ -5,7 +5,14 @@ import Web3 from 'web3';
|
||||
const rpcUrl = process.env.RPC_URL || 'ws://localhost:8545';
|
||||
|
||||
// Create a new web3 instance
|
||||
const web3 = new Web3(rpcUrl);
|
||||
const web3 = new Web3(new Web3.providers.WebsocketProvider(rpcUrl, {
|
||||
reconnect: {
|
||||
auto: true,
|
||||
delay: 5000,
|
||||
maxAttempts: 5,
|
||||
onTimeout: false
|
||||
}
|
||||
}));
|
||||
|
||||
// Get the current gas price in gwei
|
||||
async function getGasPrice() {
|
||||
|
@ -1,10 +1,11 @@
|
||||
import { Client, EmbedBuilder, TextChannel } from 'discord.js';
|
||||
import { EmbedBuilder, TextChannel } from 'discord.js';
|
||||
import { getGasPricesInGwei } from './blockchain';
|
||||
import redisClient from './redis';
|
||||
import { DiscordClient } from './discordClient';
|
||||
|
||||
import { GasAlert } from '../types/gasAlert';
|
||||
|
||||
const createGasPriceChecker = (client: Client) => {
|
||||
const createGasPriceChecker = (client: DiscordClient) => {
|
||||
setInterval(async () => {
|
||||
try {
|
||||
const gasPrices = await getGasPricesInGwei();
|
||||
|
Loading…
Reference in New Issue
Block a user