code.vegaprotocol.io/vega@v0.79.0/core/evtforward/ethereum/config.go (about) 1 // Copyright (C) 2023 Gobalsky Labs Limited 2 // 3 // This program is free software: you can redistribute it and/or modify 4 // it under the terms of the GNU Affero General Public License as 5 // published by the Free Software Foundation, either version 3 of the 6 // License, or (at your option) any later version. 7 // 8 // This program is distributed in the hope that it will be useful, 9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 // GNU Affero General Public License for more details. 12 // 13 // You should have received a copy of the GNU Affero General Public License 14 // along with this program. If not, see <http://www.gnu.org/licenses/>. 15 16 package ethereum 17 18 import ( 19 "time" 20 21 "code.vegaprotocol.io/vega/libs/config/encoding" 22 "code.vegaprotocol.io/vega/logging" 23 ) 24 25 const ( 26 defaultHeartbeatInterval = 1 * time.Hour 27 defaultDurationBetweenTwoRetry = 20 * time.Second 28 maxEthereumBlocks = 10000 // chosen because one of the validators wanted to use quicknode, and this is their limit 29 ) 30 31 type Config struct { 32 // Level specifies the logging level of the Ethereum implementation of the 33 // Event Forwarder. 34 Level encoding.LogLevel `long:"log-level"` 35 MaxEthereumBlocks uint64 `long:"max-ethereum-blocks"` 36 PollEventRetryDuration encoding.Duration 37 ChainID string 38 SkipClientVerification bool 39 HeartbeatIntervalForTestOnlyDoNotChange encoding.Duration 40 } 41 42 func NewDefaultConfig() Config { 43 return Config{ 44 Level: encoding.LogLevel{Level: logging.InfoLevel}, 45 PollEventRetryDuration: encoding.Duration{Duration: defaultDurationBetweenTwoRetry}, 46 MaxEthereumBlocks: maxEthereumBlocks, 47 HeartbeatIntervalForTestOnlyDoNotChange: encoding.Duration{Duration: defaultHeartbeatInterval}, 48 } 49 } 50 51 func (c *Config) setDefaults() { 52 if c.MaxEthereumBlocks == 0 { 53 c.MaxEthereumBlocks = maxEthereumBlocks 54 } 55 56 if c.PollEventRetryDuration.Duration == 0 { 57 c.PollEventRetryDuration.Duration = defaultDurationBetweenTwoRetry 58 } 59 60 if c.HeartbeatIntervalForTestOnlyDoNotChange.Duration == 0 { 61 c.HeartbeatIntervalForTestOnlyDoNotChange.Duration = defaultHeartbeatInterval 62 } 63 }