Skip to content

Commit

Permalink
fmt keyassignment.go
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel committed Nov 2, 2022
1 parent efdee98 commit 4730a8c
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions x/ccv/provider/keeper/keyassignment.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,14 +331,7 @@ func (ka *KeyAssignment) InternalInvariants() bool {
// address which is the address held inside
ka.Store.IterateConsumerConsAddrToLastUpdateMemo(func(cca ConsumerConsAddr, m providertypes.LastUpdateMemo) bool {
cons := PubKeyToConsAddr(*m.ConsumerKey)
if len(cca) != len(cons) {
good = false
}
for i := range cons {
if cons[i] != cca[i] {
good = false
}
}
good = good && cca.Equals(cons)
return false
})
}
Expand Down Expand Up @@ -380,6 +373,7 @@ func (s *KeyAssignmentStore) SetProviderConsAddrToConsumerPublicKey(k ProviderCo
}
s.Store.Set(providertypes.KeyAssignmentPcaToCkKey(s.ChainID, kbz), vbz)
}

func (s *KeyAssignmentStore) SetConsumerPublicKeyToProviderPublicKey(k ConsumerPublicKey, v ProviderPublicKey) {
kbz, err := k.Marshal()
if err != nil {
Expand All @@ -391,6 +385,7 @@ func (s *KeyAssignmentStore) SetConsumerPublicKeyToProviderPublicKey(k ConsumerP
}
s.Store.Set(providertypes.KeyAssignmentCkToPkKey(s.ChainID, kbz), vbz)
}

func (s *KeyAssignmentStore) SetConsumerConsAddrToLastUpdateMemo(k ConsumerConsAddr, v providertypes.LastUpdateMemo) {
kbz, err := k.Marshal()
if err != nil {
Expand All @@ -402,6 +397,7 @@ func (s *KeyAssignmentStore) SetConsumerConsAddrToLastUpdateMemo(k ConsumerConsA
}
s.Store.Set(providertypes.KeyAssignmentCcaToLastUpdateMemoKey(s.ChainID, kbz), vbz)
}

func (s *KeyAssignmentStore) GetProviderConsAddrToConsumerPublicKey(k ProviderConsAddr) (v ConsumerPublicKey, found bool) {
kbz, err := k.Marshal()
if err != nil {
Expand All @@ -416,6 +412,7 @@ func (s *KeyAssignmentStore) GetProviderConsAddrToConsumerPublicKey(k ProviderCo
}
return v, false
}

func (s *KeyAssignmentStore) GetConsumerPublicKeyToProviderPublicKey(k ConsumerPublicKey) (v ProviderPublicKey, found bool) {
kbz, err := k.Marshal()
if err != nil {
Expand All @@ -430,6 +427,7 @@ func (s *KeyAssignmentStore) GetConsumerPublicKeyToProviderPublicKey(k ConsumerP
}
return v, false
}

func (s *KeyAssignmentStore) GetConsumerConsAddrToLastUpdateMemo(k ConsumerConsAddr) (v providertypes.LastUpdateMemo, found bool) {
kbz, err := k.Marshal()
if err != nil {
Expand All @@ -445,27 +443,31 @@ func (s *KeyAssignmentStore) GetConsumerConsAddrToLastUpdateMemo(k ConsumerConsA
}
return v, false
}

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) DelConsumerPublicKeyToProviderPublicKey(k ConsumerPublicKey) {
kbz, err := k.Marshal()
if err != nil {
panic(err)
}
s.Store.Delete(providertypes.KeyAssignmentCkToPkKey(s.ChainID, kbz))
}

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) IterateProviderConsAddrToConsumerPublicKey(cb func(ProviderConsAddr, ConsumerPublicKey) bool) {
prefix := providertypes.KeyAssignmentPcaToCkChainPrefix(s.ChainID)
iterator := sdk.KVStorePrefixIterator(s.Store, prefix)
Expand All @@ -486,6 +488,7 @@ func (s *KeyAssignmentStore) IterateProviderConsAddrToConsumerPublicKey(cb func(
}
}
}

func (s *KeyAssignmentStore) IterateConsumerPublicKeyToProviderPublicKey(cb func(ConsumerPublicKey, ProviderPublicKey) bool) {
prefix := providertypes.KeyAssignmentCkToPkChainPrefix(s.ChainID)
iterator := sdk.KVStorePrefixIterator(s.Store, prefix)
Expand All @@ -506,6 +509,7 @@ func (s *KeyAssignmentStore) IterateConsumerPublicKeyToProviderPublicKey(cb func
}
}
}

func (s *KeyAssignmentStore) IterateConsumerConsAddrToLastUpdateMemo(cb func(ConsumerConsAddr, providertypes.LastUpdateMemo) bool) {
prefix := providertypes.KeyAssignmentCcaToLastUpdateMemoChainPrefix(s.ChainID)
iterator := sdk.KVStorePrefixIterator(s.Store, prefix)
Expand Down

0 comments on commit 4730a8c

Please sign in to comment.