Skip to content

Commit

Permalink
fixing
Browse files Browse the repository at this point in the history
  • Loading branch information
golangisfun123 committed Jun 20, 2024
1 parent d014dce commit b2b0ea0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
8 changes: 2 additions & 6 deletions ethergo/listener/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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
}
Expand Down
10 changes: 5 additions & 5 deletions ethergo/listener/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit b2b0ea0

Please sign in to comment.