From 1d6d5981505b6ee5bd8055a6fc48069040773711 Mon Sep 17 00:00:00 2001 From: iuwqyir Date: Thu, 17 Oct 2024 01:46:21 +0300 Subject: [PATCH] separate config for committer from block --- README.md | 11 +++++++++++ cmd/root.go | 2 ++ configs/config.go | 1 + internal/orchestrator/committer.go | 2 +- 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9a45eeb..cc25b4c 100644 --- a/README.md +++ b/README.md @@ -331,6 +331,17 @@ committer: blocksPerCommit: 1000 ``` +#### Committer From Block +From which block to start committing. Default is `0`. + +cmd: `--committer-from-block` +env: `COMMITTER_FROMBLOCK` +yaml: +```yaml +committer: + fromBlock: 20000000 +``` + #### Reorg Handler Whether to enable the reorg handler. Default is `true`. diff --git a/cmd/root.go b/cmd/root.go index fe310ab..8381c2f 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -58,6 +58,7 @@ func init() { rootCmd.PersistentFlags().Bool("committer-enabled", true, "Toggle committer") rootCmd.PersistentFlags().Int("committer-blocks-per-commit", 10, "How many blocks to commit each interval") rootCmd.PersistentFlags().Int("committer-interval", 1000, "How often to commit blocks in milliseconds") + rootCmd.PersistentFlags().Int("committer-from-block", 0, "From which block to start committing") rootCmd.PersistentFlags().Bool("reorgHandler-enabled", true, "Toggle reorg handler") rootCmd.PersistentFlags().Int("reorgHandler-interval", 1000, "How often to run reorg handler in milliseconds") rootCmd.PersistentFlags().Int("reorgHandler-blocks-per-scan", 100, "How many blocks to scan for reorgs") @@ -109,6 +110,7 @@ func init() { viper.BindPFlag("committer.enabled", rootCmd.PersistentFlags().Lookup("committer-enabled")) viper.BindPFlag("committer.blocksPerCommit", rootCmd.PersistentFlags().Lookup("committer-blocks-per-commit")) viper.BindPFlag("committer.interval", rootCmd.PersistentFlags().Lookup("committer-interval")) + viper.BindPFlag("committer.fromBlock", rootCmd.PersistentFlags().Lookup("committer-from-block")) viper.BindPFlag("reorgHandler.enabled", rootCmd.PersistentFlags().Lookup("reorgHandler-enabled")) viper.BindPFlag("reorgHandler.interval", rootCmd.PersistentFlags().Lookup("reorgHandler-interval")) viper.BindPFlag("reorgHandler.blocksPerScan", rootCmd.PersistentFlags().Lookup("reorgHandler-blocks-per-scan")) diff --git a/configs/config.go b/configs/config.go index 091146a..a45c80e 100644 --- a/configs/config.go +++ b/configs/config.go @@ -26,6 +26,7 @@ type CommitterConfig struct { Enabled bool `mapstructure:"enabled"` Interval int `mapstructure:"interval"` BlocksPerCommit int `mapstructure:"blocksPerCommit"` + FromBlock int `mapstructure:"fromBlock"` } type ReorgHandlerConfig struct { diff --git a/internal/orchestrator/committer.go b/internal/orchestrator/committer.go index 098da0e..a912758 100644 --- a/internal/orchestrator/committer.go +++ b/internal/orchestrator/committer.go @@ -39,7 +39,7 @@ func NewCommitter(rpc rpc.IRPCClient, storage storage.IStorage) *Committer { triggerIntervalMs: triggerInterval, blocksPerCommit: blocksPerCommit, storage: storage, - pollFromBlock: big.NewInt(int64(config.Cfg.Poller.FromBlock)), + pollFromBlock: big.NewInt(int64(config.Cfg.Committer.FromBlock)), rpc: rpc, } }