Skip to content

Commit

Permalink
add default finality strategy and case insensitivity
Browse files Browse the repository at this point in the history
  • Loading branch information
golangisfun123 authored Jun 21, 2024
2 parents f25026c + f10fae5 commit 6c089de
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ethergo/listener/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package listener

import (
"context"
"strings"
"time"

"github.com/ethereum/go-ethereum/rpc"
Expand Down Expand Up @@ -30,13 +31,15 @@ func WithPollInterval(interval time.Duration) Option {
// WithFinalityMode sets the finality mode.
func WithFinalityMode(mode string) Option {
return func(c *chainListener) {
switch mode {
switch strings.ToLower(mode) {
case "latest":
c.finalityMode = rpc.LatestBlockNumber
case "safe":
c.finalityMode = rpc.SafeBlockNumber
case "finalized":
c.finalityMode = rpc.FinalizedBlockNumber
default:
c.finalityMode = rpc.SafeBlockNumber
}
}
}
Expand Down

0 comments on commit 6c089de

Please sign in to comment.