Skip to content

Commit

Permalink
Revert "fix uncaught error" (#450)
Browse files Browse the repository at this point in the history
This reverts commit 2c32f13.

Co-authored-by: mouseless <97399882+mouseless-eth@users.noreply.github.com>
  • Loading branch information
mouseless0x and mouseless0x authored Feb 28, 2025
1 parent 2c32f13 commit f053cc2
Showing 1 changed file with 17 additions and 58 deletions.
75 changes: 17 additions & 58 deletions src/handlers/gasPriceManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,46 +71,11 @@ export class GasPriceManager {
// Periodically update gas prices if specified
if (this.config.gasPriceRefreshInterval > 0) {
setInterval(() => {
try {
if (this.config.legacyTransactions === false) {
this.updateBaseFee().catch((error) => {
this.logger.error(
{ error },
"Failed to update base fee in interval"
)
sentry.captureException(error)
})
}

this.tryUpdateGasPrice().catch((error) => {
this.logger.error(
{ error },
"Failed to update gas price in interval"
)
sentry.captureException(error)
})
} catch (error) {
this.logger.error(
{ error },
"Unexpected error in gas price update interval"
)
sentry.captureException(error)
}
}, this.config.gasPriceRefreshInterval * 1000)
setInterval(() => {
try {
if (this.config.legacyTransactions === false) {
this.updateBaseFee()
}

this.tryUpdateGasPrice()
} catch (error) {
this.logger.error(
{ error },
"Unexpected error in during gasPrices refresh interval"
)
sentry.captureException(error)
if (this.config.legacyTransactions === false) {
this.updateBaseFee()
}

this.tryUpdateGasPrice()
}, this.config.gasPriceRefreshInterval * 1000)
}

Expand Down Expand Up @@ -409,28 +374,22 @@ export class GasPriceManager {
}

public async getBaseFee(): Promise<bigint> {
try {
if (this.config.legacyTransactions) {
throw new RpcError(
"baseFee is not available for legacy transactions"
)
}

if (this.config.gasPriceRefreshInterval === 0) {
return await this.updateBaseFee()
}
if (this.config.legacyTransactions) {
throw new RpcError(
"baseFee is not available for legacy transactions"
)
}

let baseFee = this.baseFeePerGasQueue.getLatestValue()
if (!baseFee) {
baseFee = await this.updateBaseFee()
}
if (this.config.gasPriceRefreshInterval === 0) {
return await this.updateBaseFee()
}

return baseFee
} catch (error) {
this.logger.error({ error }, "Failed to get base fee")
sentry.captureException(error)
throw new RpcError("Failed to get network baseFee")
let baseFee = this.baseFeePerGasQueue.getLatestValue()
if (!baseFee) {
baseFee = await this.updateBaseFee()
}

return baseFee
}

// This method throws if it can't get a valid RPC response.
Expand Down

0 comments on commit f053cc2

Please sign in to comment.