Commit 7006abff authored by vicotor's avatar vicotor

add chain sync interval

parent 6bb4f378
...@@ -143,6 +143,11 @@ func (s *ChainSync) loop() { ...@@ -143,6 +143,11 @@ func (s *ChainSync) loop() {
}).Info("validator block") }).Info("validator block")
beginHeight = endHeight + 1 beginHeight = endHeight + 1
if s.syncmode {
tm.Reset(time.Second)
} else {
tm.Reset(time.Second * time.Duration(s.chain.Interval))
}
} }
} }
} }
......
...@@ -20,6 +20,7 @@ type ChainConfig struct { ...@@ -20,6 +20,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
//ValidatorPrivateKey string `toml:"validator_private_key"` //ValidatorPrivateKey string `toml:"validator_private_key"`
ChainId int64 `toml:"chain_id"` // Will be populated by code ChainId int64 `toml:"chain_id"` // Will be populated by code
} }
...@@ -65,6 +66,9 @@ func New(confPath string) (*Config, error) { ...@@ -65,6 +66,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