wormchain: wormhole: Use existing helper functions

Replace a couple of blocks with existing helper functions that do the
same thing.
This commit is contained in:
Chirantan Ekbote 2022-08-22 17:02:03 +09:00 committed by Chirantan Ekbote
parent a0c25dead2
commit 991c41b46e
1 changed files with 2 additions and 6 deletions

View File

@ -19,7 +19,7 @@ func (k Keeper) UpdateGuardianSet(ctx sdk.Context, newGuardianSet types.Guardian
return types.ErrNoConfig
}
oldSet, exists := k.GetGuardianSet(ctx, k.GetGuardianSetCount(ctx)-1)
oldSet, exists := k.GetGuardianSet(ctx, k.GetLatestGuardianSetIndex(ctx))
if !exists {
return types.ErrGuardianSetNotFound
}
@ -136,11 +136,7 @@ func (k Keeper) AppendGuardianSet(
return 0, types.ErrGuardianSetNotSequential
}
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.GuardianSetKey))
appendedValue := k.cdc.MustMarshal(&guardianSet)
store.Set(GetGuardianSetIDBytes(guardianSet.Index), appendedValue)
// Update guardianSet count
k.setGuardianSet(ctx, guardianSet)
k.setGuardianSetCount(ctx, count+1)
return count, nil