Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

core: Automatically unquote config fields if needed

  • Loading branch information
albrow committed Jul 25, 2019
commit d402f582d5e489e5d0db510e29f6912938eff9d9
@@ -9,6 +9,7 @@ import (
"fmt"
"os"
"path/filepath"
"strconv"
"sync"
"time"

@@ -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")
@@ -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)
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.