Skip to content

Commit

Permalink
update GetAllValidatorsByConsumerAddr
Browse files Browse the repository at this point in the history
  • Loading branch information
Yaru Wang committed Sep 8, 2023
1 parent 24b89ed commit 7060c45
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions x/ccv/provider/keeper/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,17 @@ func ValidatorConsensusKeyInUse(k *Keeper, ctx sdk.Context, valAddr sdk.ValAddre
panic("could not get validator cons addr ")
}

inUse := false

for _, validatorConsumerAddrs := range k.GetAllValidatorsByConsumerAddr(ctx, nil) {
if sdk.ConsAddress(validatorConsumerAddrs.ConsumerAddr).Equals(consensusAddr) {
inUse = true
break
consumerChains := k.GetAllConsumerChains(ctx)
for _, consumerChain := range consumerChains {
if _, exist := k.GetValidatorByConsumerAddr(
ctx,
consumerChain.ChainId,
providertypes.NewConsumerConsAddress(consensusAddr)); exist {
return true
}
}

return inUse
return false
}

func (h Hooks) AfterValidatorCreated(ctx sdk.Context, valAddr sdk.ValAddress) error {
Expand Down

0 comments on commit 7060c45

Please sign in to comment.