Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
golangisfun123 committed Jun 20, 2024
1 parent b2b0ea0 commit 32ce20c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion ethergo/listener/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func NewChainListener(omnirpcClient client.EVM, store listenerDB.ChainListenerDB
client: omnirpcClient,
backoff: newBackoffConfig(),
pollIntervalSetting: time.Millisecond * 50,
finalityMode: FinalityModeLatest,
finalityMode: rpc.LatestBlockNumber,
blockWait: 0,
}

Expand Down
23 changes: 13 additions & 10 deletions ethergo/listener/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,21 @@ func WithPollInterval(interval time.Duration) Option {
}
}

const (
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.
func WithFinalityMode(mode rpc.BlockNumber) Option {
func WithFinalityMode(mode string) Option {
return func(c *chainListener) {
c.finalityMode = mode
switch mode {
case "latest":
c.finalityMode = rpc.LatestBlockNumber
case "earliest":
c.finalityMode = rpc.EarliestBlockNumber
case "pending":
c.finalityMode = rpc.PendingBlockNumber
case "safe":
c.finalityMode = rpc.SafeBlockNumber
case "finalized":
c.finalityMode = rpc.FinalizedBlockNumber
}
}
}

Expand Down

0 comments on commit 32ce20c

Please sign in to comment.