diff --git a/cmd/tendermint/run_node.go b/cmd/tendermint/run_node.go index 9f13533a5..a66451541 100644 --- a/cmd/tendermint/run_node.go +++ b/cmd/tendermint/run_node.go @@ -34,9 +34,12 @@ func run_node(config cfg.Config) { if err != nil { Exit(Fmt("Couldn't read GenesisDoc file: %v", err)) } - genDoc := types.GenesisDocFromJSON(jsonBlob) + genDoc, err := types.GenesisDocFromJSON(jsonBlob) + if err != nil { + Exit(Fmt("Error reading GenesisDoc: %v", err)) + } if genDoc.ChainID == "" { - PanicSanity(Fmt("Genesis doc %v must include non-empty chain_id", genDocFile)) + Exit(Fmt("Genesis doc %v must include non-empty chain_id", genDocFile)) } config.Set("chain_id", genDoc.ChainID) } diff --git a/state/state.go b/state/state.go index 455ba4093..f4af8ee01 100644 --- a/state/state.go +++ b/state/state.go @@ -166,7 +166,10 @@ func MakeGenesisStateFromFile(db dbm.DB, genDocFile string) *State { if err != nil { Exit(Fmt("Couldn't read GenesisDoc file: %v", err)) } - genDoc := types.GenesisDocFromJSON(genDocJSON) + genDoc, err := types.GenesisDocFromJSON(genDocJSON) + if err != nil { + Exit(Fmt("Error reading GenesisDoc: %v", err)) + } return MakeGenesisState(db, genDoc) } diff --git a/types/genesis.go b/types/genesis.go index 9c81bc2d2..3a0395488 100644 --- a/types/genesis.go +++ b/types/genesis.go @@ -38,11 +38,7 @@ func (genDoc *GenesisDoc) SaveAs(file string) error { //------------------------------------------------------------ // Make genesis state from file -func GenesisDocFromJSON(jsonBlob []byte) (genState *GenesisDoc) { - var err error - wire.ReadJSONPtr(&genState, jsonBlob, &err) - if err != nil { - Exit(Fmt("Couldn't read GenesisDoc: %v", err)) - } +func GenesisDocFromJSON(jsonBlob []byte) (genDoc *GenesisDoc, err error) { + wire.ReadJSONPtr(&genDoc, jsonBlob, &err) return } diff --git a/types/validator_set.go b/types/validator_set.go index 3f5a17d9a..a3b2838cb 100644 --- a/types/validator_set.go +++ b/types/validator_set.go @@ -252,6 +252,32 @@ func (valSet *ValidatorSet) VerifyCommit(chainID string, blockID BlockID, height } } +// Verify that +2/3 of this set had signed the given signBytes. +// Unlike VerifyCommit(), this function can verify commits with differeent sets. +func (valSet *ValidatorSet) VerifyCommitAny(chainID string, blockID BlockID, height int, commit *Commit) error { + panic("Not yet implemented") + /* + Start like: + + FOR_LOOP: + for _, val := range vals { + if len(precommits) == 0 { + break FOR_LOOP + } + next := precommits[0] + switch bytes.Compare(val.Address(), next.ValidatorAddress) { + case -1: + continue FOR_LOOP + case 0: + signBytes := tm.SignBytes(next) + ... + case 1: + ... // error? + } + } + */ +} + func (valSet *ValidatorSet) String() string { return valSet.StringIndented("") }