Clean up genesis parse per Anton

This commit is contained in:
Ethan Frey 2017-10-20 13:45:54 +02:00
parent 822b6a3fef
commit ba27d23ad1
1 changed files with 6 additions and 2 deletions

View File

@ -10,6 +10,10 @@ import (
cmn "github.com/tendermint/tmlibs/common"
)
// KeyDelimiter is used to separate module and key in
// the options
const KeyDelimiter = "/"
// Option just holds module/key/value triples from
// parsing the genesis file
type Option struct {
@ -141,8 +145,8 @@ func parseList(kvzIn []json.RawMessage) (kvz []keyValue, err error) {
// Splits the string at the first '/'.
// if there are none, assign default module ("base").
func splitKey(key string) (string, string) {
if strings.Contains(key, "/") {
keyParts := strings.SplitN(key, "/", 2)
if strings.Contains(key, KeyDelimiter) {
keyParts := strings.SplitN(key, KeyDelimiter, 2)
return keyParts[0], keyParts[1]
}
return sdk.ModuleNameBase, key