diff --git a/ethergo/listener/listener.go b/ethergo/listener/listener.go index ccd5ca7a05..9f59c1b0d5 100644 --- a/ethergo/listener/listener.go +++ b/ethergo/listener/listener.go @@ -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, } diff --git a/ethergo/listener/options.go b/ethergo/listener/options.go index b71ffb7c3a..97f87b20ac 100644 --- a/ethergo/listener/options.go +++ b/ethergo/listener/options.go @@ -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 + } } }