store subspace

This commit is contained in:
rigelrozanski 2018-01-25 21:11:40 +00:00
parent 6b9d836f40
commit e00f285379
2 changed files with 8 additions and 2 deletions

View File

@ -265,7 +265,7 @@ func removeValidatorFromKey(store types.KVStore, pubKey crypto.PubKey) {
// is to modify the VotingPower
func getValidators(store types.KVStore, maxVal int) Validators {
iterator := store.Iterator(ValidatorKeyPrefix, ValidatorKeyPrefix) //smallest to largest
iterator := store.Iterator(subspace(ValidatorKeyPrefix)) //smallest to largest
validators := make(Validators, maxVal)
for i := 0; ; i++ {
@ -291,7 +291,7 @@ func getValidators(store types.KVStore, maxVal int) Validators {
// loadCandidates - get the active list of all candidates TODO replace with multistore
func loadCandidates(store types.KVStore) (candidates Candidates) {
iterator := store.Iterator(CandidateKeyPrefix, CandidateKeyPrefix) //smallest to largest
iterator := store.Iterator(subspace(CandidateKeyPrefix)) //smallest to largest
for i := 0; ; i++ {
if !iterator.Valid() {

View File

@ -9,6 +9,12 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
)
func subspace(prefix []byte) (start, end []byte) {
start, end = prefix, prefix
end[len(end)-1]++
return
}
func newAddrs(n int) (addrs []crypto.Address) {
for i := 0; i < n; i++ {
addrs = append(addrs, []byte(fmt.Sprintf("addr%d", i)))