Skip to content

Commit

Permalink
Renam store methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel committed Nov 2, 2022
1 parent eaf08cd commit 8affd7b
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 80 deletions.
2 changes: 1 addition & 1 deletion tests/difference/core/driver/core_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ func (s *CoreSuite) deliver(chain string, numPackets int) {
func (s *CoreSuite) readCurrentKeyAssignment() map[int64]providerkeeper.ConsumerPublicKey {
k := s.providerKeeper()
assignment := map[int64]providerkeeper.ConsumerPublicKey{}
k.KeyAssignment(s.ctx(P), s.chainID(C)).Store.IteratePcaToCk(func(pca providerkeeper.ProviderConsAddr, consumerPubKey providerkeeper.ConsumerPublicKey) bool {
k.KeyAssignment(s.ctx(P), s.chainID(C)).Store.IterateProviderConsAddrToConsumerPublicKey(func(pca providerkeeper.ProviderConsAddr, consumerPubKey providerkeeper.ConsumerPublicKey) bool {
for val := int64(0); val < int64(initState.NumValidators); val++ {
consAddr := s.consAddr(val)
if consAddr.Equals(pca) {
Expand Down
12 changes: 6 additions & 6 deletions x/ccv/provider/keeper/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ func (k Keeper) InitGenesis(ctx sdk.Context, genState *types.GenesisState) {
}
if cs.KeyAssignment != nil {
for _, pcaToCk := range cs.KeyAssignment.ProviderConsAddrToConsumerKey {
k.KeyAssignment(ctx, cs.ChainId).Store.SetPcaToCk(pcaToCk.ConsAddr, *pcaToCk.Key)
k.KeyAssignment(ctx, cs.ChainId).Store.SetProviderConsAddrToConsumerPublicKey(pcaToCk.ConsAddr, *pcaToCk.Key)
}
for _, ckToPk := range cs.KeyAssignment.ConsumerKeyToProviderKey {
k.KeyAssignment(ctx, cs.ChainId).Store.SetCkToPk(*ckToPk.From, *ckToPk.To)
k.KeyAssignment(ctx, cs.ChainId).Store.SetConsumerPublicKeyToProviderPublicKey(*ckToPk.From, *ckToPk.To)
}
for _, ccaToLastUpdateMemo := range cs.KeyAssignment.ConsumerConsAddrToLastUpdateMemo {
k.KeyAssignment(ctx, cs.ChainId).Store.SetCcaToLastUpdateMemo(ccaToLastUpdateMemo.ConsAddr, *ccaToLastUpdateMemo.LastUpdateMemo)
k.KeyAssignment(ctx, cs.ChainId).Store.SetConsumerConsAddrToLastUpdateMemo(ccaToLastUpdateMemo.ConsAddr, *ccaToLastUpdateMemo.LastUpdateMemo)
}
}
}
Expand Down Expand Up @@ -134,15 +134,15 @@ func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState {
km.ProviderConsAddrToConsumerKey = []ccv.ConsAddrToKey{}
km.ConsumerKeyToProviderKey = []ccv.KeyToKey{}
km.ConsumerConsAddrToLastUpdateMemo = []ccv.ConsAddrToLastUpdateMemo{}
k.KeyAssignment(ctx, chainID).Store.IteratePcaToCk(func(pca ProviderConsAddr, ck ConsumerPublicKey) bool {
k.KeyAssignment(ctx, chainID).Store.IterateProviderConsAddrToConsumerPublicKey(func(pca ProviderConsAddr, ck ConsumerPublicKey) bool {
km.ProviderConsAddrToConsumerKey = append(km.ProviderConsAddrToConsumerKey, ccv.ConsAddrToKey{ConsAddr: pca, Key: &ck})
return false
})
k.KeyAssignment(ctx, chainID).Store.IterateCkToPk(func(ck ConsumerPublicKey, pk ProviderPublicKey) bool {
k.KeyAssignment(ctx, chainID).Store.IterateConsumerPublicKeyToProviderPublicKey(func(ck ConsumerPublicKey, pk ProviderPublicKey) bool {
km.ConsumerKeyToProviderKey = append(km.ConsumerKeyToProviderKey, ccv.KeyToKey{From: &ck, To: &pk})
return false
})
k.KeyAssignment(ctx, chainID).Store.IterateCcaToLastUpdateMemo(func(ck ConsumerConsAddr, m ccv.LastUpdateMemo) bool {
k.KeyAssignment(ctx, chainID).Store.IterateConsumerConsAddrToLastUpdateMemo(func(ck ConsumerConsAddr, m ccv.LastUpdateMemo) bool {
km.ConsumerConsAddrToLastUpdateMemo = append(km.ConsumerConsAddrToLastUpdateMemo, ccv.ConsAddrToLastUpdateMemo{ConsAddr: ck, LastUpdateMemo: &m})
return false
})
Expand Down
4 changes: 2 additions & 2 deletions x/ccv/provider/keeper/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ func TestIniAndExportGenesis(t *testing.T) {
require.True(t, pk.GetPendingConsumerRemovalProp(ctx, cChainIDs[0], oneHourFromNow))
require.Equal(t, pGenesis.Params, pk.GetParams(ctx))

_, found = pk.KeyAssignment(ctx, cChainIDs[0]).Store.GetPcaToCk(sdk.ConsAddress{})
_, found = pk.KeyAssignment(ctx, cChainIDs[0]).Store.GetProviderConsAddrToConsumerPublicKey(sdk.ConsAddress{})
require.True(t, found)
_, found = pk.KeyAssignment(ctx, cChainIDs[1]).Store.GetPcaToCk(sdk.ConsAddress{})
_, found = pk.KeyAssignment(ctx, cChainIDs[1]).Store.GetProviderConsAddrToConsumerPublicKey(sdk.ConsAddress{})
require.False(t, found)

// check provider chain's consumer chain states
Expand Down
110 changes: 55 additions & 55 deletions x/ccv/provider/keeper/keyassignment.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,18 @@ func PubKeyToConsAddr(k tmprotocrypto.PublicKey) sdk.ConsAddress {
}

type Store interface {
SetPcaToCk(ProviderConsAddr, ConsumerPublicKey)
SetCkToPk(ConsumerPublicKey, ProviderPublicKey)
SetCcaToLastUpdateMemo(ConsumerConsAddr, ccvtypes.LastUpdateMemo)
GetPcaToCk(ProviderConsAddr) (ConsumerPublicKey, bool)
GetCkToPk(ConsumerPublicKey) (ProviderPublicKey, bool)
GetCcaToLastUpdateMemo(ConsumerConsAddr) (ccvtypes.LastUpdateMemo, bool)
DelPcaToCk(ProviderConsAddr)
DelCkToPk(ConsumerPublicKey)
DelCcaToLastUpdateMemo(ConsumerConsAddr)
IteratePcaToCk(func(ProviderConsAddr, ConsumerPublicKey) bool)
IterateCkToPk(func(ConsumerPublicKey, ProviderPublicKey) bool)
IterateCcaToLastUpdateMemo(func(ConsumerConsAddr, ccvtypes.LastUpdateMemo) bool)
SetProviderConsAddrToConsumerPublicKey(ProviderConsAddr, ConsumerPublicKey)
SetConsumerPublicKeyToProviderPublicKey(ConsumerPublicKey, ProviderPublicKey)
SetConsumerConsAddrToLastUpdateMemo(ConsumerConsAddr, ccvtypes.LastUpdateMemo)
GetProviderConsAddrToConsumerPublicKey(ProviderConsAddr) (ConsumerPublicKey, bool)
GetConsumerPublicKeyToProviderPublicKey(ConsumerPublicKey) (ProviderPublicKey, bool)
GetConsumerConsAddrToLastUpdateMemo(ConsumerConsAddr) (ccvtypes.LastUpdateMemo, bool)
DelProviderConsAddrToConsumerPublicKey(ProviderConsAddr)
DelConsumerPublicKeyToProviderPublicKey(ConsumerPublicKey)
DelConsumerConsAddrToLastUpdateMemo(ConsumerConsAddr)
IterateProviderConsAddrToConsumerPublicKey(func(ProviderConsAddr, ConsumerPublicKey) bool)
IterateConsumerPublicKeyToProviderPublicKey(func(ConsumerPublicKey, ProviderPublicKey) bool)
IterateConsumerConsAddrToLastUpdateMemo(func(ConsumerConsAddr, ccvtypes.LastUpdateMemo) bool)
}

type KeyAssignment struct {
Expand All @@ -62,66 +62,66 @@ func MakeKeyAssignment(store Store) KeyAssignment {
}

func (ka *KeyAssignment) SetProviderPubKeyToConsumerPubKey(pk ProviderPublicKey, ck ConsumerPublicKey) error {
if _, ok := ka.Store.GetCkToPk(ck); ok {
if _, ok := ka.Store.GetConsumerPublicKeyToProviderPublicKey(ck); ok {
return errors.New(`cannot reuse key which is in use or was recently in use`)
}
if _, ok := ka.Store.GetCcaToLastUpdateMemo(PubKeyToConsAddr(ck)); ok {
if _, ok := ka.Store.GetConsumerConsAddrToLastUpdateMemo(PubKeyToConsAddr(ck)); ok {
return errors.New(`cannot reuse key which is in use or was recently in use`)
}
pca := PubKeyToConsAddr(pk)
if oldCk, ok := ka.Store.GetPcaToCk(pca); ok {
ka.Store.DelCkToPk(oldCk)
if oldCk, ok := ka.Store.GetProviderConsAddrToConsumerPublicKey(pca); ok {
ka.Store.DelConsumerPublicKeyToProviderPublicKey(oldCk)
}
ka.Store.SetPcaToCk(pca, ck)
ka.Store.SetCkToPk(ck, pk)
ka.Store.SetProviderConsAddrToConsumerPublicKey(pca, ck)
ka.Store.SetConsumerPublicKeyToProviderPublicKey(ck, pk)
return nil
}

func (ka *KeyAssignment) DeleteProviderKey(pca ProviderConsAddr) error {
// TODO: document expensive operation
if ck, ok := ka.Store.GetPcaToCk(pca); ok {
ka.Store.DelCkToPk(ck)
if ck, ok := ka.Store.GetProviderConsAddrToConsumerPublicKey(pca); ok {
ka.Store.DelConsumerPublicKeyToProviderPublicKey(ck)
}
ka.Store.DelPcaToCk(pca)
ka.Store.DelProviderConsAddrToConsumerPublicKey(pca)
toDelete := []ConsumerConsAddr{}
ka.Store.IterateCcaToLastUpdateMemo(func(cca ConsumerConsAddr, lum ccvtypes.LastUpdateMemo) bool {
ka.Store.IterateConsumerConsAddrToLastUpdateMemo(func(cca ConsumerConsAddr, lum ccvtypes.LastUpdateMemo) bool {
pcaInMemo := PubKeyToConsAddr(*lum.ProviderKey)
if pca.Equals(pcaInMemo) { // TODO: find other place where I should have used Equals
toDelete = append(toDelete, cca)
}
return false
})
for _, cca := range toDelete {
ka.Store.DelCcaToLastUpdateMemo(cca)
ka.Store.DelConsumerConsAddrToLastUpdateMemo(cca)
}
return nil
}

func (ka *KeyAssignment) GetCurrentConsumerPubKeyFromProviderPubKey(pk ProviderPublicKey) (ck ConsumerPublicKey, found bool) {
return ka.Store.GetPcaToCk(PubKeyToConsAddr(pk))
return ka.Store.GetProviderConsAddrToConsumerPublicKey(PubKeyToConsAddr(pk))
}

func (ka *KeyAssignment) GetProviderPubKeyFromConsumerPubKey(ck ConsumerPublicKey) (pk ProviderPublicKey, found bool) {
return ka.Store.GetCkToPk(ck)
return ka.Store.GetConsumerPublicKeyToProviderPublicKey(ck)
}

func (ka *KeyAssignment) GetProviderPubKeyFromConsumerConsAddress(cca sdk.ConsAddress) (pk ProviderPublicKey, found bool) {
if memo, found := ka.Store.GetCcaToLastUpdateMemo(cca); found {
if memo, found := ka.Store.GetConsumerConsAddrToLastUpdateMemo(cca); found {
return *memo.ProviderKey, true
}
return pk, false
}

func (ka *KeyAssignment) PruneUnusedKeys(latestVscid VSCID) {
toDel := []ConsumerConsAddr{}
ka.Store.IterateCcaToLastUpdateMemo(func(cca ConsumerConsAddr, m ccvtypes.LastUpdateMemo) bool {
ka.Store.IterateConsumerConsAddrToLastUpdateMemo(func(cca ConsumerConsAddr, m ccvtypes.LastUpdateMemo) bool {
if m.Power == 0 && m.Vscid <= latestVscid {
toDel = append(toDel, cca)
}
return false
})
for _, cca := range toDel {
ka.Store.DelCcaToLastUpdateMemo(cca)
ka.Store.DelConsumerConsAddrToLastUpdateMemo(cca)
}
}

Expand All @@ -134,9 +134,9 @@ func (ka *KeyAssignment) getProviderKeysForUpdate(stakingUpdates map[ProviderPub
// Get provider keys which the consumer is aware of, because the
// last update sent to the consumer was a positive power update
// and the assigned key has changed since that update.
ka.Store.IterateCcaToLastUpdateMemo(func(cca ConsumerConsAddr, m ccvtypes.LastUpdateMemo) bool {
ka.Store.IterateConsumerConsAddrToLastUpdateMemo(func(cca ConsumerConsAddr, m ccvtypes.LastUpdateMemo) bool {
pca := PubKeyToConsAddr(*m.ProviderKey)
if newCk, ok := ka.Store.GetPcaToCk(pca); ok { // TODO: do away with ok, should always be ok
if newCk, ok := ka.Store.GetProviderConsAddrToConsumerPublicKey(pca); ok { // TODO: do away with ok, should always be ok
oldCk := m.ConsumerKey
if !oldCk.Equal(newCk) && 0 < m.Power {
keys = append(keys, *m.ProviderKey)
Expand All @@ -160,7 +160,7 @@ func (ka *KeyAssignment) getProviderKeysForUpdate(stakingUpdates map[ProviderPub

func (ka KeyAssignment) getProviderKeysLastPositiveUpdate(mustCreateUpdate map[string]bool) map[string]ccvtypes.LastUpdateMemo {
lastUpdate := map[string]ccvtypes.LastUpdateMemo{}
ka.Store.IterateCcaToLastUpdateMemo(func(_ ConsumerConsAddr, m ccvtypes.LastUpdateMemo) bool {
ka.Store.IterateConsumerConsAddrToLastUpdateMemo(func(_ ConsumerConsAddr, m ccvtypes.LastUpdateMemo) bool {
s := DeterministicStringify(*m.ProviderKey)
if 0 < m.Power {
if _, found := mustCreateUpdate[s]; found {
Expand Down Expand Up @@ -196,7 +196,7 @@ func (ka *KeyAssignment) getConsumerUpdates(vscid VSCID, stakingUpdates map[Prov
canonicalConsumerKey[s] = *u.ConsumerKey
consumerUpdates[*u.ConsumerKey] = 0
cca := PubKeyToConsAddr(*u.ConsumerKey)
ka.Store.SetCcaToLastUpdateMemo(cca, ccvtypes.LastUpdateMemo{ConsumerKey: u.ConsumerKey, ProviderKey: &pk, Vscid: vscid, Power: 0})
ka.Store.SetConsumerConsAddrToLastUpdateMemo(cca, ccvtypes.LastUpdateMemo{ConsumerKey: u.ConsumerKey, ProviderKey: &pk, Vscid: vscid, Power: 0})
}
}

Expand Down Expand Up @@ -224,12 +224,12 @@ func (ka *KeyAssignment) getConsumerUpdates(vscid VSCID, stakingUpdates map[Prov

// Only ship update with positive powers.
if 0 < power {
ck, found := ka.Store.GetPcaToCk(PubKeyToConsAddr(pk))
ck, found := ka.Store.GetProviderConsAddrToConsumerPublicKey(PubKeyToConsAddr(pk))
if !found {
panic("must find ck for pk")
}
cca := PubKeyToConsAddr(ck)
ka.Store.SetCcaToLastUpdateMemo(cca, ccvtypes.LastUpdateMemo{ConsumerKey: &ck, ProviderKey: &pk, Vscid: vscid, Power: power})
ka.Store.SetConsumerConsAddrToLastUpdateMemo(cca, ccvtypes.LastUpdateMemo{ConsumerKey: &ck, ProviderKey: &pk, Vscid: vscid, Power: power})
if k, found := canonicalConsumerKey[DeterministicStringify(ck)]; found {
consumerUpdates[k] = power
} else {
Expand Down Expand Up @@ -271,7 +271,7 @@ func (ka *KeyAssignment) InternalInvariants() bool {
// No two provider keys can map to the same consumer key
// (pkToCk is sane)
seen := map[string]bool{}
ka.Store.IteratePcaToCk(func(_ ProviderConsAddr, ck ConsumerPublicKey) bool {
ka.Store.IterateProviderConsAddrToConsumerPublicKey(func(_ ProviderConsAddr, ck ConsumerPublicKey) bool {
if seen[DeterministicStringify(ck)] {
good = false
}
Expand All @@ -283,8 +283,8 @@ func (ka *KeyAssignment) InternalInvariants() bool {
{
// All values of pkToCk is a key of ckToPk
// (reverse lookup is always possible)
ka.Store.IteratePcaToCk(func(pca ProviderConsAddr, ck ConsumerPublicKey) bool {
if pkQueried, ok := ka.Store.GetCkToPk(ck); ok {
ka.Store.IterateProviderConsAddrToConsumerPublicKey(func(pca ProviderConsAddr, ck ConsumerPublicKey) bool {
if pkQueried, ok := ka.Store.GetConsumerPublicKeyToProviderPublicKey(ck); ok {
pcaQueried := PubKeyToConsAddr(pkQueried)
good = good && string(pcaQueried) == string(pca)
} else {
Expand All @@ -298,9 +298,9 @@ func (ka *KeyAssignment) InternalInvariants() bool {
// All consumer keys mapping to provider keys are actually
// mapped to by the provider key.
// (ckToPk is sane)
ka.Store.IterateCkToPk(func(ck ConsumerPublicKey, _ ProviderPublicKey) bool {
ka.Store.IterateConsumerPublicKeyToProviderPublicKey(func(ck ConsumerPublicKey, _ ProviderPublicKey) bool {
found := false
ka.Store.IteratePcaToCk(func(_ ProviderConsAddr, candidateCk ConsumerPublicKey) bool {
ka.Store.IterateProviderConsAddrToConsumerPublicKey(func(_ ProviderConsAddr, candidateCk ConsumerPublicKey) bool {
if candidateCk.Equal(ck) {
found = true
return true
Expand All @@ -317,8 +317,8 @@ func (ka *KeyAssignment) InternalInvariants() bool {
// any memo containing the same consumer key has the same
// mapping.
// (Ensures lookups are correct)
ka.Store.IterateCkToPk(func(ck ConsumerPublicKey, pk ProviderPublicKey) bool {
if m, ok := ka.Store.GetCcaToLastUpdateMemo(PubKeyToConsAddr(ck)); ok {
ka.Store.IterateConsumerPublicKeyToProviderPublicKey(func(ck ConsumerPublicKey, pk ProviderPublicKey) bool {
if m, ok := ka.Store.GetConsumerConsAddrToLastUpdateMemo(PubKeyToConsAddr(ck)); ok {
if !pk.Equal(m.ProviderKey) {
good = false
}
Expand All @@ -330,7 +330,7 @@ func (ka *KeyAssignment) InternalInvariants() bool {
{
// All entries in ckToMemo have a consumer consensus
// address which is the address held inside
ka.Store.IterateCcaToLastUpdateMemo(func(cca ConsumerConsAddr, m ccvtypes.LastUpdateMemo) bool {
ka.Store.IterateConsumerConsAddrToLastUpdateMemo(func(cca ConsumerConsAddr, m ccvtypes.LastUpdateMemo) bool {
cons := PubKeyToConsAddr(*m.ConsumerKey)
if len(cca) != len(cons) {
good = false
Expand All @@ -348,7 +348,7 @@ func (ka *KeyAssignment) InternalInvariants() bool {
// The set of all LastUpdateMemos with positive power
// has pairwise unique provider keys
seen := map[string]bool{}
ka.Store.IterateCcaToLastUpdateMemo(func(_ ConsumerConsAddr, m ccvtypes.LastUpdateMemo) bool {
ka.Store.IterateConsumerConsAddrToLastUpdateMemo(func(_ ConsumerConsAddr, m ccvtypes.LastUpdateMemo) bool {
if 0 < m.Power {
s := DeterministicStringify(*m.ProviderKey)
if _, ok := seen[s]; ok {
Expand All @@ -370,7 +370,7 @@ type KeyAssignmentStore struct {
ChainID string
}

func (s *KeyAssignmentStore) SetPcaToCk(k ProviderConsAddr, v ConsumerPublicKey) {
func (s *KeyAssignmentStore) SetProviderConsAddrToConsumerPublicKey(k ProviderConsAddr, v ConsumerPublicKey) {
kbz, err := k.Marshal()
if err != nil {
panic(err)
Expand All @@ -381,7 +381,7 @@ func (s *KeyAssignmentStore) SetPcaToCk(k ProviderConsAddr, v ConsumerPublicKey)
}
s.Store.Set(providertypes.KeyAssignmentPcaToCkKey(s.ChainID, kbz), vbz)
}
func (s *KeyAssignmentStore) SetCkToPk(k ConsumerPublicKey, v ProviderPublicKey) {
func (s *KeyAssignmentStore) SetConsumerPublicKeyToProviderPublicKey(k ConsumerPublicKey, v ProviderPublicKey) {
kbz, err := k.Marshal()
if err != nil {
panic(err)
Expand All @@ -392,7 +392,7 @@ func (s *KeyAssignmentStore) SetCkToPk(k ConsumerPublicKey, v ProviderPublicKey)
}
s.Store.Set(providertypes.KeyAssignmentCkToPkKey(s.ChainID, kbz), vbz)
}
func (s *KeyAssignmentStore) SetCcaToLastUpdateMemo(k ConsumerConsAddr, v ccvtypes.LastUpdateMemo) {
func (s *KeyAssignmentStore) SetConsumerConsAddrToLastUpdateMemo(k ConsumerConsAddr, v ccvtypes.LastUpdateMemo) {
kbz, err := k.Marshal()
if err != nil {
panic(err)
Expand All @@ -403,7 +403,7 @@ func (s *KeyAssignmentStore) SetCcaToLastUpdateMemo(k ConsumerConsAddr, v ccvtyp
}
s.Store.Set(providertypes.KeyAssignmentCcaToLastUpdateMemoKey(s.ChainID, kbz), vbz)
}
func (s *KeyAssignmentStore) GetPcaToCk(k ProviderConsAddr) (v ConsumerPublicKey, found bool) {
func (s *KeyAssignmentStore) GetProviderConsAddrToConsumerPublicKey(k ProviderConsAddr) (v ConsumerPublicKey, found bool) {
kbz, err := k.Marshal()
if err != nil {
panic(err)
Expand All @@ -417,7 +417,7 @@ func (s *KeyAssignmentStore) GetPcaToCk(k ProviderConsAddr) (v ConsumerPublicKey
}
return v, false
}
func (s *KeyAssignmentStore) GetCkToPk(k ConsumerPublicKey) (v ProviderPublicKey, found bool) {
func (s *KeyAssignmentStore) GetConsumerPublicKeyToProviderPublicKey(k ConsumerPublicKey) (v ProviderPublicKey, found bool) {
kbz, err := k.Marshal()
if err != nil {
panic(err)
Expand All @@ -431,7 +431,7 @@ func (s *KeyAssignmentStore) GetCkToPk(k ConsumerPublicKey) (v ProviderPublicKey
}
return v, false
}
func (s *KeyAssignmentStore) GetCcaToLastUpdateMemo(k ConsumerConsAddr) (v ccvtypes.LastUpdateMemo, found bool) {
func (s *KeyAssignmentStore) GetConsumerConsAddrToLastUpdateMemo(k ConsumerConsAddr) (v ccvtypes.LastUpdateMemo, found bool) {
kbz, err := k.Marshal()
if err != nil {
panic(err)
Expand All @@ -446,28 +446,28 @@ func (s *KeyAssignmentStore) GetCcaToLastUpdateMemo(k ConsumerConsAddr) (v ccvty
}
return v, false
}
func (s *KeyAssignmentStore) DelPcaToCk(k ProviderConsAddr) {
func (s *KeyAssignmentStore) DelProviderConsAddrToConsumerPublicKey(k ProviderConsAddr) {
kbz, err := k.Marshal()
if err != nil {
panic(err)
}
s.Store.Delete(providertypes.KeyAssignmentPcaToCkKey(s.ChainID, kbz))
}
func (s *KeyAssignmentStore) DelCkToPk(k ConsumerPublicKey) {
func (s *KeyAssignmentStore) DelConsumerPublicKeyToProviderPublicKey(k ConsumerPublicKey) {
kbz, err := k.Marshal()
if err != nil {
panic(err)
}
s.Store.Delete(providertypes.KeyAssignmentCkToPkKey(s.ChainID, kbz))
}
func (s *KeyAssignmentStore) DelCcaToLastUpdateMemo(k ConsumerConsAddr) {
func (s *KeyAssignmentStore) DelConsumerConsAddrToLastUpdateMemo(k ConsumerConsAddr) {
kbz, err := k.Marshal()
if err != nil {
panic(err)
}
s.Store.Delete(providertypes.KeyAssignmentCcaToLastUpdateMemoKey(s.ChainID, kbz))
}
func (s *KeyAssignmentStore) IteratePcaToCk(cb func(ProviderConsAddr, ConsumerPublicKey) bool) {
func (s *KeyAssignmentStore) IterateProviderConsAddrToConsumerPublicKey(cb func(ProviderConsAddr, ConsumerPublicKey) bool) {
prefix := providertypes.KeyAssignmentPcaToCkChainPrefix(s.ChainID)
iterator := sdk.KVStorePrefixIterator(s.Store, prefix)
defer iterator.Close()
Expand All @@ -487,7 +487,7 @@ func (s *KeyAssignmentStore) IteratePcaToCk(cb func(ProviderConsAddr, ConsumerPu
}
}
}
func (s *KeyAssignmentStore) IterateCkToPk(cb func(ConsumerPublicKey, ProviderPublicKey) bool) {
func (s *KeyAssignmentStore) IterateConsumerPublicKeyToProviderPublicKey(cb func(ConsumerPublicKey, ProviderPublicKey) bool) {
prefix := providertypes.KeyAssignmentCkToPkChainPrefix(s.ChainID)
iterator := sdk.KVStorePrefixIterator(s.Store, prefix)
defer iterator.Close()
Expand All @@ -507,7 +507,7 @@ func (s *KeyAssignmentStore) IterateCkToPk(cb func(ConsumerPublicKey, ProviderPu
}
}
}
func (s *KeyAssignmentStore) IterateCcaToLastUpdateMemo(cb func(ConsumerConsAddr, ccvtypes.LastUpdateMemo) bool) {
func (s *KeyAssignmentStore) IterateConsumerConsAddrToLastUpdateMemo(cb func(ConsumerConsAddr, ccvtypes.LastUpdateMemo) bool) {
prefix := providertypes.KeyAssignmentCcaToLastUpdateMemoChainPrefix(s.ChainID)
iterator := sdk.KVStorePrefixIterator(s.Store, prefix)
defer iterator.Close()
Expand Down
Loading

0 comments on commit 8affd7b

Please sign in to comment.