github.com/TrueBlocks/trueblocks-core/src/apps/chifra@v0.0.0-20241022031540-b362680128f7/internal/daemon/validate.go (about) 1 // Copyright 2021 The TrueBlocks Authors. All rights reserved. 2 // Use of this source code is governed by a license that can 3 // be found in the LICENSE file. 4 5 package daemonPkg 6 7 import ( 8 "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/config" 9 "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/validate" 10 ) 11 12 func (opts *DaemonOptions) validateDaemon() error { 13 chain := opts.Globals.Chain 14 15 opts.testLog() 16 17 if opts.BadFlag != nil { 18 return opts.BadFlag 19 } 20 21 if !config.IsChainConfigured(chain) { 22 return validate.Usage("chain {0} is not properly configured.", chain) 23 } 24 25 if opts.Globals.IsApiMode() { 26 return validate.Usage("The {0} option is not available{1}.", "daemon", " in api mode") 27 } 28 29 if opts.Grpc { 30 return validate.Usage("The {0} option is deprecated. There is no replacement.", "--grpc") 31 } 32 33 // validate.ValidateEnum("scrape", opts.Scrape, "[off|blooms|index]") 34 // validate.ValidateEnum("api", opts.Api, "[off|on]") 35 opts.Api = "on" 36 37 if len(opts.Scrape) > 0 { 38 return validate.Usage("The {0} option is currenlty not available. Use {1} instead.", "--scrape", "chifra scrape") 39 } 40 41 if opts.Monitor { 42 return validate.Usage("The {0} option is currenlty not available. Use {1} instead.", "--monitor", "chifra monitors --watch") 43 } 44 45 return opts.Globals.Validate() 46 }