state save/load test.

This commit is contained in:
Jae Kwon
2014-10-07 00:43:34 -07:00
parent b73b7a54c7
commit 08f86176fc
11 changed files with 99 additions and 15 deletions
+15
View File
@@ -5,6 +5,7 @@ import (
. "github.com/tendermint/tendermint/binary"
. "github.com/tendermint/tendermint/common"
"github.com/tendermint/tendermint/merkle"
)
// Holds state for a Validator at a given height+round.
@@ -155,3 +156,17 @@ func (vset *ValidatorSet) GetProposer() (proposer *Validator) {
}
return
}
// Should uniquely determine the state of the ValidatorSet.
func (vset *ValidatorSet) Hash() []byte {
ids := []uint64{}
for id, _ := range vset.validators {
ids = append(ids, id)
}
UInt64Slice(ids).Sort()
sortedValidators := make([]Binary, len(ids))
for i, id := range ids {
sortedValidators[i] = vset.validators[id]
}
return merkle.HashFromBinaries(sortedValidators)
}