Skip to content

Commit

Permalink
add storage location cfg option
Browse files Browse the repository at this point in the history
  • Loading branch information
cam-schultz committed Aug 29, 2023
1 parent 5ca0bd0 commit ba3f2fb
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 2 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
Expand All @@ -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.
Expand Down
1 change: 1 addition & 0 deletions config/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ const (
DestinationSubnetsKey = "destination-subnets"
EncryptConnectionKey = "encrypt-connection"
AccountPrivateKeyKey = "account-private-key"
StorageLocationKey = "storage-location"
)
4 changes: 1 addition & 3 deletions main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ const (
defaultErrorChanSize = 1000
defaultApiPort = 8080
defaultMetricsPort = 9090

defaultStorageLocation = "~/.awm-relayer"
)

func main() {
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit ba3f2fb

Please sign in to comment.