Skip to content

Commit

Permalink
Del unused store methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel committed Oct 25, 2022
1 parent 4ab1956 commit 9e6c82e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 63 deletions.
52 changes: 2 additions & 50 deletions x/ccv/provider/keeper/keymap.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
- [ ] default mapping should be inserted whenever a validator update goes out for a previously unseen validator
- [ ] it must be possible to change a mapping via a tx submitted to the provider
- [ ] it must be possible to query current mappings (via rpc? how?)
- [ ] garbage collect pkToCk, ckToPk, ccaToCk if appropriate, when validator is destroyed
- [ ] garbage collect pkToCk, ckToPk if appropriate, when validator is destroyed
## Quality list
Expand Down Expand Up @@ -98,19 +98,15 @@ type Store interface {
SetPkToCk(ProviderPubKey, ConsumerPubKey)
SetCkToPk(ConsumerPubKey, ProviderPubKey)
SetCkToMemo(ConsumerConsAddr, ccvtypes.LastUpdateMemo)
// SetCcaToCk(ConsumerConsAddr, ConsumerPubKey)
GetPkToCk(ProviderPubKey) (ConsumerPubKey, bool)
GetCkToPk(ConsumerPubKey) (ProviderPubKey, bool)
GetCkToMemo(ConsumerConsAddr) (ccvtypes.LastUpdateMemo, bool)
// GetCcaToCk(ConsumerConsAddr) (ConsumerPubKey, bool)
DelPkToCk(ProviderPubKey)
DelCkToPk(ConsumerPubKey)
DelCkToMemo(ConsumerConsAddr)
// DelCcaToCk(ConsumerConsAddr)
IteratePkToCk(func(ProviderPubKey, ConsumerPubKey) bool)
IterateCkToPk(func(ConsumerPubKey, ProviderPubKey) bool)
IterateCkToMemo(func(ConsumerConsAddr, ccvtypes.LastUpdateMemo) bool)
// IterateCcaToCk(func(ConsumerConsAddr, ConsumerPubKey) bool)
}

type KeyMap struct {
Expand Down Expand Up @@ -399,14 +395,7 @@ func (s *KeyMapStore) SetCkToMemo(k ConsumerConsAddr, v ccvtypes.LastUpdateMemo)
}
s.Store.Set(types.KeyMapCkToMemoKey(s.ChainID, kbz), vbz)
}
func (s *KeyMapStore) SetCcaToCk(k ConsumerConsAddr, v ConsumerPubKey) {
kbz := []byte(k)
vbz, err := v.Marshal()
if err != nil {
panic(err)
}
s.Store.Set(types.KeyMapCcaToCkKey(s.ChainID, kbz), vbz)
}

func (s *KeyMapStore) GetPkToCk(k ProviderPubKey) (v ConsumerPubKey, found bool) {
kbz, err := k.Marshal()
if err != nil {
Expand Down Expand Up @@ -450,20 +439,6 @@ func (s *KeyMapStore) GetCkToMemo(k ConsumerConsAddr) (v ccvtypes.LastUpdateMemo
}
return v, false
}
func (s *KeyMapStore) GetCcaToCk(k ConsumerConsAddr) (v ConsumerPubKey, found bool) {
kbz, err := k.Marshal()
if err != nil {
panic(err)
}
if vbz := s.Store.Get(types.KeyMapCcaToCkKey(s.ChainID, kbz)); vbz != nil {
err := v.Unmarshal(vbz)
if err != nil {
panic(err)
}
return v, true
}
return v, false
}

func (s *KeyMapStore) DelPkToCk(k ProviderPubKey) {
kbz, err := k.Marshal()
Expand All @@ -486,13 +461,6 @@ func (s *KeyMapStore) DelCkToMemo(k ConsumerConsAddr) {
}
s.Store.Delete(types.KeyMapCkToMemoKey(s.ChainID, kbz))
}
func (s *KeyMapStore) DelCcaToCk(k ConsumerConsAddr) {
kbz, err := k.Marshal()
if err != nil {
panic(err)
}
s.Store.Delete(types.KeyMapCcaToCkKey(s.ChainID, kbz))
}

func (s *KeyMapStore) IteratePkToCk(cb func(ProviderPubKey, ConsumerPubKey) bool) {
prefix := types.KeyMapPkToCkChainPrefix(s.ChainID)
Expand Down Expand Up @@ -555,22 +523,6 @@ func (s *KeyMapStore) IterateCkToMemo(cb func(ConsumerConsAddr, ccvtypes.LastUpd
}
}
}
func (s *KeyMapStore) IterateCcaToCk(cb func(ConsumerConsAddr, ConsumerPubKey) bool) {
prefix := types.KeyMapCcaToCkChainPrefix(s.ChainID)
iterator := sdk.KVStorePrefixIterator(s.Store, prefix)
defer iterator.Close()
for ; iterator.Valid(); iterator.Next() {
k := sdk.ConsAddress(iterator.Key()[len(prefix):])
v := ConsumerPubKey{}
err := v.Unmarshal(iterator.Value())
if err != nil {
panic(err)
}
if cb(k, v) {
return
}
}
}

func (k Keeper) KeyMap(ctx sdk.Context, chainID string) *KeyMap {
store := KeyMapStore{ctx.KVStore(k.storeKey), chainID}
Expand Down
13 changes: 0 additions & 13 deletions x/ccv/provider/types/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,6 @@ const (

// TODO:
KeyMapCkToMemoPrefix

// TODO:
KeyMapCcaToCkPrefix
)

const (
Expand Down Expand Up @@ -286,11 +283,6 @@ func KeyMapCkToMemoChainPrefix(chainID string) []byte {
return append([]byte{KeyMapCkToMemoPrefix}, []byte(chainID)...)
}

// TODO:
func KeyMapCcaToCkChainPrefix(chainID string) []byte {
return append([]byte{KeyMapCcaToCkPrefix}, []byte(chainID)...)
}

// TODO:
func KeyMapPkToCkKey(chainID string, kbz []byte) []byte {
return append(KeyMapPkToCkChainPrefix(chainID), kbz...)
Expand All @@ -306,11 +298,6 @@ func KeyMapCkToMemoKey(chainID string, kbz []byte) []byte {
return append(KeyMapCkToMemoChainPrefix(chainID), kbz...)
}

// TODO:
func KeyMapCcaToCkKey(chainID string, kbz []byte) []byte {
return append(KeyMapCcaToCkChainPrefix(chainID), kbz...)
}

// AppendMany appends a variable number of byte slices together
func AppendMany(byteses ...[]byte) (out []byte) {
for _, bytes := range byteses {
Expand Down

0 comments on commit 9e6c82e

Please sign in to comment.