code.vegaprotocol.io/vega@v0.79.0/datanode/networkhistory/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 networkhistory 17 18 import ( 19 "time" 20 21 "code.vegaprotocol.io/vega/datanode/config/encoding" 22 "code.vegaprotocol.io/vega/datanode/networkhistory/snapshot" 23 "code.vegaprotocol.io/vega/datanode/networkhistory/store" 24 "code.vegaprotocol.io/vega/logging" 25 ) 26 27 type Config struct { 28 Level encoding.LogLevel `long:"log-level"` 29 Enabled encoding.Bool `description:"set to false to disable network history" long:"enabled"` 30 WipeOnStartup encoding.Bool `description:"deprecated and ignored, use data-node unsafe_reset_all command instead" long:"wipe-on-startup"` 31 32 Publish encoding.Bool `description:"if true this node will create and publish network history segments" long:"publish"` 33 34 Store store.Config `group:"Store" namespace:"store"` 35 Snapshot snapshot.Config `group:"Snapshot" namespace:"snapshot"` 36 37 FetchRetryMax int `description:"maximum number of times to retry fetching segments - default 10" long:"fetch-retry-max"` 38 RetryTimeout encoding.Duration `description:"time to wait between retries, increases with each retry - default 5s" long:"retry-timeout"` 39 40 Initialise InitializationConfig `group:"Initialise" namespace:"initialise"` 41 } 42 43 // NewDefaultConfig creates an instance of the package specific configuration, given a 44 // pointer to a logger instance to be used for logging within the package. 45 func NewDefaultConfig() Config { 46 return Config{ 47 Level: encoding.LogLevel{Level: logging.InfoLevel}, 48 Enabled: true, 49 Publish: true, 50 Store: store.NewDefaultConfig(), 51 Snapshot: snapshot.NewDefaultConfig(), 52 FetchRetryMax: 10, 53 RetryTimeout: encoding.Duration{Duration: 5 * time.Second}, 54 Initialise: NewDefaultInitializationConfig(), 55 } 56 } 57 58 func NewDefaultInitializationConfig() InitializationConfig { 59 return InitializationConfig{ 60 MinimumBlockCount: 4_200_000, 61 TimeOut: encoding.Duration{Duration: 6 * time.Hour}, 62 GrpcAPIPorts: []int{}, 63 ToSegment: "", 64 } 65 } 66 67 type InitializationConfig struct { 68 ToSegment string `description:"the segment to initialise up to, if omitted the datanode will attempt to fetch the latest segment from the network" long:"to-segment"` 69 MinimumBlockCount int64 `description:"the minimum number of blocks to fetch" long:"block-count"` 70 TimeOut encoding.Duration `description:"maximum time allowed to auto-initialise the node" long:"timeout"` 71 GrpcAPIPorts []int `description:"list of additional ports to check to for api connection when getting latest segment" long:"grpc-api-ports"` 72 }