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

[GOAL2-624] Add a kmd_config.json.example to the installer dir #112

Merged
merged 4 commits into from
Jul 3, 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
9 changes: 8 additions & 1 deletion daemon/kmd/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@ import (
"encoding/json"
"io/ioutil"
"path/filepath"

"github.com/algorand/go-algorand/util/codecs"
)

const (
kmdConfigFilename = "kmd_config.json"
kmdConfigExampleFilename = kmdConfigFilename + ".example"
defaultSessionLifetimeSecs = 60
defaultScryptN = 65536
defaultScryptR = 1
Expand Down Expand Up @@ -95,8 +98,12 @@ func LoadKMDConfig(dataDir string) (cfg KMDConfig, err error) {
cfg = defaultConfig(dataDir)
configFilename := filepath.Join(dataDir, kmdConfigFilename)
dat, err := ioutil.ReadFile(configFilename)
// Return the default configuration if the file doesn't exist
// If there is no config file, then return the default configuration, and dump the default config to disk
if err != nil {
exampleFilename := filepath.Join(dataDir, kmdConfigExampleFilename)
Copy link
Contributor

@Karmastic Karmastic Jul 3, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use codecs.SaveObjectToFile() and save it formatted.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where to modify the default configuration ip and port?

// SaveObjectToFile may return an unhandled error because
// there is nothing to do if an error occurs
codecs.SaveObjectToFile(exampleFilename, cfg, true)
return cfg, nil
}
// Fill in the non-default values
Expand Down