From 02448881fb313249afceeaf8ffcf93d0d59879dc Mon Sep 17 00:00:00 2001 From: kien6034 Date: Fri, 26 Apr 2024 09:24:14 +0700 Subject: [PATCH] perf: use byte array for grant's keys --- x/authz/keeper/keeper.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/x/authz/keeper/keeper.go b/x/authz/keeper/keeper.go index 396209cf611f..3c8cae7ec45a 100644 --- a/x/authz/keeper/keeper.go +++ b/x/authz/keeper/keeper.go @@ -258,10 +258,10 @@ func (k Keeper) DeleteGrant(ctx context.Context, grantee, granter sdk.AccAddress // DeleteAllGrants revokes all authorizations granted to the grantee by the granter. func (k Keeper) DeleteAllGrants(ctx context.Context, granter sdk.AccAddress) error { - var keysToDelete []string + var keysToDelete [][]byte err := k.IterateGranterGrants(ctx, granter, func(grantee sdk.AccAddress, msgType string) (stop bool, err error) { - keysToDelete = append(keysToDelete, string(grantStoreKey(grantee, granter, msgType))) + keysToDelete = append(keysToDelete, grantStoreKey(grantee, granter, msgType)) return false, nil }) if err != nil { @@ -271,7 +271,7 @@ func (k Keeper) DeleteAllGrants(ctx context.Context, granter sdk.AccAddress) err return errorsmod.Wrapf(authz.ErrNoAuthorizationFound, "no grants found for granter %s", granter) } for _, key := range keysToDelete { - _, granteeAddr, msgType := parseGrantStoreKey([]byte(key)) + _, granteeAddr, msgType := parseGrantStoreKey(key) if err := k.DeleteGrant(ctx, granteeAddr, granter, msgType); err != nil { return err }