Fix config bug where chain_id is default magic. Always read from genesis

This commit is contained in:
Jae Kwon
2015-10-20 17:39:03 -07:00
parent df733fbaa5
commit 7c12c5aee3
6 changed files with 74 additions and 36 deletions

View File

@ -2,6 +2,7 @@ package node
import (
"bytes"
"io/ioutil"
"math/rand"
"net"
"net/http"
@ -297,6 +298,16 @@ func RunNode() {
if FileExists(genDocFile) {
break
}
jsonBlob, err := ioutil.ReadFile(genDocFile)
if err != nil {
Exit(Fmt("Couldn't read GenesisDoc file: %v", err))
}
genDoc := stypes.GenesisDocFromJSON(jsonBlob)
if genDoc.ChainID == "" {
PanicSanity(Fmt("Genesis doc %v must include non-empty chain_id", genDocFile))
}
config.Set("chain_id", genDoc.ChainID)
config.Set("genesis_doc", genDoc)
}
}