func LoadConfig(fileLocation string, vip *viper.Viper) (err error) {
	if fileLocation == "" {
		fileLocation = defaultConfigFileName
	}
	vip.SetConfigFile(fileLocation)
	err = vip.ReadInConfig()
	if err != nil {
		if fileLocation != defaultConfigFileName {
			log.Warning("failed loading config from %v trying %v", fileLocation, defaultConfigFileName)
			vip.SetConfigFile(defaultConfigFileName)
			err = vip.ReadInConfig()
		}
		if err != nil {
			return fmt.Errorf("failed to read config file %v", err)
		}
	}
	return nil
}
LoadConfig load the config file
package config
import (
	"fmt"
	"path/filepath"
	"time"
	"github.com/libonomy/libonomy-p2p/filesystem"
	"github.com/libonomy/libonomy-p2p/log"
	p2pConfig "github.com/libonomy/libonomy-p2p/p2p/config"
	"github.com/spf13/viper"
)
const (
	defaultConfigFileName  = "./config.toml"
	defaultLogFileName     = "libonomy.log"
	defaultAccountFileName = "accounts"
	defaultDataDirName     = "libonomy"
	NewBlockProtocol = "newBlock"
)
var (
	defaultHomeDir    = filesystem.GetUserHomeDirectory()
	defaultDataDir    = filepath.Join(defaultHomeDir, defaultDataDirName, "/")
	defaultLogDir     = filepath.Join(defaultHomeDir, defaultLogFileName)
	defaultAccountDir = filepath.Join(defaultHomeDir, defaultAccountFileName)
	defaultTestMode   = false
)
type Config struct {
	BaseConfig `mapstructure:"main"`
	P2P        p2pConfig.Config `mapstructure:"p2p"`
}
type BaseConfig struct {
	HomeDir string
	DataDir string `mapstructure:"data-folder"`
	ConfigFile string `mapstructure:"config"`
	LogDir string `mapstructure:"log-dir"`
	AccountDir string `mapstructure:"account-dir"`
	TestMode bool `mapstructure:"test-mode"`
	CollectMetrics bool `mapstructure:"metrics"`
	MetricsPort    int  `mapstructure:"metrics-port"`
	OracleServer        string `mapstructure:"oracle_server"`
	OracleServerWorldID int    `mapstructure:"oracle_server_worldid"`
	GenesisTime      string `mapstructure:"genesis-time"`
	LayerDurationSec int    `mapstructure:"layer-duration-sec"`
	LayerAvgSize     int    `mapstructure:"layer-average-size"`
	LayersPerEpoch   int    `mapstructure:"layers-per-epoch"`
	Hdist            int    `mapstructure:"hdist"`
	PoETServer string `mapstructure:"poet-server"`
	MemProfile string `mapstructure:"mem-profile"`
	CPUProfile string `mapstructure:"cpu-profile"`
	PprofHTTPServer bool `mapstructure:"pprof-server"`
	GenesisConfPath string `mapstructure:"genesis-conf"`
	CoinbaseAccount string `mapstructure:"coinbase"`
	GenesisActiveSet int `mapstructure:"genesis-active-size"`  
	SyncRequestTimeout int `mapstructure:"sync-request-timeout"`  
	SyncInterval int `mapstructure:"sync-interval"`  
	SyncValidationDelta int `mapstructure:"sync-validation-delta"`  
	PublishEventsURL string `mapstructure:"events-url"`
	StartMining bool `mapstructure:"start-mining"`
	AtxsPerBlock int `mapstructure:"atxs-per-block"`
	BlockCacheSize int `mapstructure:"block-cache-size"`
}
type LoggerConfig struct {
	P2PLoggerLevel string `mapstructure:"p2p"`
}
func DefaultConfig() Config {
	return Config{
		BaseConfig: defaultBaseConfig(),
		P2P:        p2pConfig.DefaultConfig(),
	}
}
func defaultBaseConfig() BaseConfig {
	return BaseConfig{
		HomeDir:             defaultHomeDir,
		DataDir:             defaultDataDir,
		ConfigFile:          defaultConfigFileName,
		LogDir:              defaultLogDir,
		AccountDir:          defaultAccountDir,
		TestMode:            defaultTestMode,
		CollectMetrics:      false,
		MetricsPort:         1010,
		OracleServer:        "http://localhost:3030",
		OracleServerWorldID: 0,
		GenesisTime:         time.Now().Format(time.RFC3339),
		LayerDurationSec:    30,
		LayersPerEpoch:      3,
		PoETServer:          "127.0.0.1",
		Hdist:               5,
		GenesisActiveSet:    5,
		BlockCacheSize:      20,
		SyncRequestTimeout:  2000,
		SyncInterval:        10,
		SyncValidationDelta: 30,
		AtxsPerBlock:        100,
	}
}