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