github.com/TrueBlocks/trueblocks-core/src/apps/chifra@v0.0.0-20241022031540-b362680128f7/pkg/config/chainGroup.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 config 6 7 import "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/configtypes" 8 9 // GetChain returns the chain for a given chain 10 func GetChain(chain string) configtypes.ChainGroup { 11 return GetRootConfig().Chains[chain] 12 } 13 14 // GetChains returns a list of all chains configured in the config file. Note, there is no "official" 15 // list. Users may add their own chains. 16 func GetChains() []configtypes.ChainGroup { 17 chainArray := make([]configtypes.ChainGroup, 0, len(GetRootConfig().Chains)) 18 for _, v := range GetRootConfig().Chains { 19 chainArray = append(chainArray, v) 20 } 21 return chainArray 22 } 23 24 // IsChainConfigured returns true if the chain is configured in the config file. 25 func IsChainConfigured(needle string) bool { 26 return GetRootConfig().Chains != nil && GetRootConfig().Chains[needle] != configtypes.ChainGroup{} 27 }