Commit fcc5a061 authored by vicotor's avatar vicotor

add chain sync interval

parent 80722eb4
...@@ -161,9 +161,14 @@ func (s *ChainSync) loop() { ...@@ -161,9 +161,14 @@ func (s *ChainSync) loop() {
"end height": endHeight, "end height": endHeight,
"latest height": latestHeight, "latest height": latestHeight,
"diff height": latestHeight - endHeight, "diff height": latestHeight - endHeight,
}).Info("backend block") }).Debug("backend block")
beginHeight = endHeight + 1 beginHeight = endHeight + 1
if s.syncmode {
tm.Reset(time.Second)
} else {
tm.Reset(time.Duration(s.chain.Interval) * time.Second)
}
} }
} }
} }
......
...@@ -19,6 +19,7 @@ type ChainConfig struct { ...@@ -19,6 +19,7 @@ type ChainConfig struct {
BatchBlock int `toml:"batch_block"` BatchBlock int `toml:"batch_block"`
BehindBlock int `toml:"behind_block"` BehindBlock int `toml:"behind_block"`
BridgeContract string `toml:"bridge_contract"` BridgeContract string `toml:"bridge_contract"`
Interval int `toml:"interval"` // in seconds
ChainId int64 `toml:"chain_id"` // Will be populated by code ChainId int64 `toml:"chain_id"` // Will be populated by code
} }
...@@ -71,6 +72,9 @@ func New(confPath string) (*Config, error) { ...@@ -71,6 +72,9 @@ func New(confPath string) (*Config, error) {
// Convert to map for easier access // Convert to map for easier access
for _, chain := range chainArray { for _, chain := range chainArray {
chainCopy := chain // Create a copy to avoid pointer issues chainCopy := chain // Create a copy to avoid pointer issues
if chainCopy.Interval <= 0 {
chainCopy.Interval = 2
}
cfg.Chains[chain.Name] = &chainCopy cfg.Chains[chain.Name] = &chainCopy
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment