Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

core: Automatically unquote config fields if needed #306

Merged
merged 1 commit into from
Jul 26, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"fmt"
"os"
"path/filepath"
"strconv"
"sync"
"time"

Expand Down Expand Up @@ -126,6 +127,7 @@ func New(config Config) (*App, error) {
if config.EthereumRPCMaxContentLength < maxOrderSizeInBytes {
return nil, fmt.Errorf("Cannot set `EthereumRPCMaxContentLength` to be less then maxOrderSizeInBytes: %d", maxOrderSizeInBytes)
}
config = unquoteConfig(config)

// Initialize db
databasePath := filepath.Join(config.DataDir, "db")
Expand Down Expand Up @@ -216,6 +218,17 @@ func New(config Config) (*App, error) {
return app, nil
}

// unquoteConfig removes quotes (if needed) from each string field in config.
func unquoteConfig(config Config) Config {
if unquotedEthereumRPCURL, err := strconv.Unquote(config.EthereumRPCURL); err == nil {
config.EthereumRPCURL = unquotedEthereumRPCURL
}
if unquotedDataDir, err := strconv.Unquote(config.DataDir); err == nil {
config.DataDir = unquotedDataDir
}
return config
}

func getPubSubTopic(networkID int) string {
return fmt.Sprintf("/0x-orders/network/%d/version/1", networkID)
}
Expand Down