From b2b0ea0eb5164b2971b81b5d1f27b95c1db77155 Mon Sep 17 00:00:00 2001 From: golangisfun123 Date: Thu, 20 Jun 2024 17:55:34 -0500 Subject: [PATCH] fixing --- ethergo/listener/listener.go | 8 ++------ ethergo/listener/options.go | 10 +++++----- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/ethergo/listener/listener.go b/ethergo/listener/listener.go index 8c02dba98f..ccd5ca7a05 100644 --- a/ethergo/listener/listener.go +++ b/ethergo/listener/listener.go @@ -137,7 +137,7 @@ func (c *chainListener) doPoll(parentCtx context.Context, handler HandleLog) (er }() oldLatestBlock := c.latestBlock - c.latestBlock, err = c.client.BlockNumber(ctx) + c.latestBlock, err = c.getBlockNumber(ctx) if err != nil { return fmt.Errorf("could not get block number: %w", err) } @@ -189,11 +189,7 @@ func (c *chainListener) doPoll(parentCtx context.Context, handler HandleLog) (er } func (c chainListener) getBlockNumber(ctx context.Context) (uint64, error) { - var block *types.Block - var err error - - block, err = c.client.BlockByNumber(ctx, big.NewInt(c.finalityMode.Int64())) - + block, err := c.client.BlockByNumber(ctx, big.NewInt(c.finalityMode.Int64())) if err != nil { return 0, err } diff --git a/ethergo/listener/options.go b/ethergo/listener/options.go index c0e976efcf..b71ffb7c3a 100644 --- a/ethergo/listener/options.go +++ b/ethergo/listener/options.go @@ -27,12 +27,12 @@ func WithPollInterval(interval time.Duration) Option { } } -// FinalityMode represents the finality mode for block queries. - const ( - FinalityModeSafe rpc.BlockNumber = rpc.SafeBlockNumber - FinalityModeFinalized rpc.BlockNumber = rpc.FinalizedBlockNumber - FinalityModeLatest rpc.BlockNumber = rpc.FinalizedBlockNumber + FinalityModeSafe rpc.BlockNumber = rpc.SafeBlockNumber + FinalityModeFinalized rpc.BlockNumber = rpc.FinalizedBlockNumber + FinalityModeLatest rpc.BlockNumber = rpc.LatestBlockNumber + FinalityModePending rpc.BlockNumber = rpc.PendingBlockNumber + FinalityModeEarliestBlockNumber rpc.BlockNumber = rpc.EarliestBlockNumber ) // WithFinalityMode sets the finality mode.