Browse Source

Cleanup, add stub for VerifyCommitAny

pull/386/head
Jae Kwon 8 years ago
parent
commit
67ab574e98
4 changed files with 37 additions and 9 deletions
  1. +5
    -2
      cmd/tendermint/run_node.go
  2. +4
    -1
      state/state.go
  3. +2
    -6
      types/genesis.go
  4. +26
    -0
      types/validator_set.go

+ 5
- 2
cmd/tendermint/run_node.go View File

@ -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)
}


+ 4
- 1
state/state.go View File

@ -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)
}


+ 2
- 6
types/genesis.go View File

@ -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
}

+ 26
- 0
types/validator_set.go View File

@ -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("")
}


Loading…
Cancel
Save