From ba3f2fb6c794b05c33c9a46b83966fa03faa12ec Mon Sep 17 00:00:00 2001 From: cam-schultz Date: Tue, 29 Aug 2023 21:49:20 +0000 Subject: [PATCH] add storage location cfg option --- config/config.go | 2 ++ config/keys.go | 1 + main/main.go | 4 +--- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/config/config.go b/config/config.go index 5bc04613..84e6729b 100644 --- a/config/config.go +++ b/config/config.go @@ -63,6 +63,7 @@ type Config struct { NetworkID uint32 `mapstructure:"network-id" json:"network-id"` PChainAPIURL string `mapstructure:"p-chain-api-url" json:"p-chain-api-url"` EncryptConnection bool `mapstructure:"encrypt-connection" json:"encrypt-connection"` + StorageLocation string `mapstructure:"storage-location" json:"storage-location"` SourceSubnets []SourceSubnet `mapstructure:"source-subnets" json:"source-subnets"` DestinationSubnets []DestinationSubnet `mapstructure:"destination-subnets" json:"destination-subnets"` } @@ -72,6 +73,7 @@ func SetDefaultConfigValues(v *viper.Viper) { v.SetDefault(NetworkIDKey, constants.MainnetID) v.SetDefault(PChainAPIURLKey, "https://api.avax.network") v.SetDefault(EncryptConnectionKey, true) + v.SetDefault(StorageLocationKey, "./awm-relayer-storage") } // BuildConfig constructs the relayer config using Viper. diff --git a/config/keys.go b/config/keys.go index a9beb607..d872a0e1 100644 --- a/config/keys.go +++ b/config/keys.go @@ -13,4 +13,5 @@ const ( DestinationSubnetsKey = "destination-subnets" EncryptConnectionKey = "encrypt-connection" AccountPrivateKeyKey = "account-private-key" + StorageLocationKey = "storage-location" ) diff --git a/main/main.go b/main/main.go index 40dc87cf..9661fc7b 100644 --- a/main/main.go +++ b/main/main.go @@ -34,8 +34,6 @@ const ( defaultErrorChanSize = 1000 defaultApiPort = 8080 defaultMetricsPort = 9090 - - defaultStorageLocation = "~/.awm-relayer" ) func main() { @@ -153,7 +151,7 @@ func main() { } // Initialize the database - db, err := database.NewJSONFileStorage(logger, defaultStorageLocation, sourceChainIDs) + db, err := database.NewJSONFileStorage(logger, cfg.StorageLocation, sourceChainIDs) if err != nil { logger.Error( "Failed to create database",