Skip to content

Commit

Permalink
remove test func
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgao001 committed Dec 29, 2023
1 parent 639c0a6 commit 83dc886
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 32 deletions.
1 change: 0 additions & 1 deletion x/permission/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ import (

func EndBlocker(ctx sdk.Context, k keeper.Keeper) {
k.RemoveExpiredPolicies(ctx)
k.CountAccountPolicy(ctx)
}
32 changes: 1 addition & 31 deletions x/permission/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ func (k Keeper) MigrateAccountPolicyForResources(ctx sdk.Context) {
resourceAccountPolicyStore := prefix.NewStore(store, resourcePolicyForAccountPrefix)
iterator := resourceAccountPolicyStore.Iterator(nil, nil)
for ; iterator.Valid(); iterator.Next() {
resourceIDBz := iterator.Value()[:len(iterator.Key())-sdk.EthAddressLength]
resourceIDBz := iterator.Key()[:len(iterator.Key())-sdk.EthAddressLength]
addrBz := iterator.Key()[len(iterator.Key())-sdk.EthAddressLength:]
resourceAccountPolicyStore.Delete(iterator.Key())

Expand All @@ -622,33 +622,3 @@ func (k Keeper) MigrateAccountPolicyForResources(ctx sdk.Context) {
migration(types.ObjectPolicyForAccountPrefix, resource.RESOURCE_TYPE_OBJECT)
migration(types.GroupPolicyForAccountPrefix, resource.RESOURCE_TYPE_GROUP)
}

func (k Keeper) CountAccountPolicy(ctx sdk.Context) {
store := ctx.KVStore(k.storeKey)
resourceAccountsPolicyStore := prefix.NewStore(store, types.BucketPolicyForAccountPrefix)
iterator := resourceAccountsPolicyStore.Iterator(nil, nil)
bTotal := 0
defer iterator.Close()
for ; iterator.Valid(); iterator.Next() {
bTotal++
}
fmt.Printf("bucket policy %d\n", bTotal)

resourceAccountsPolicyStore = prefix.NewStore(store, types.ObjectPolicyForAccountPrefix)
iterator = resourceAccountsPolicyStore.Iterator(nil, nil)
oTotal := 0
defer iterator.Close()
for ; iterator.Valid(); iterator.Next() {
oTotal++
}
fmt.Printf("object policy %d\n", oTotal)

resourceAccountsPolicyStore = prefix.NewStore(store, types.GroupPolicyForAccountPrefix)
iterator = resourceAccountsPolicyStore.Iterator(nil, nil)
gTotal := 0
defer iterator.Close()
for ; iterator.Valid(); iterator.Next() {
gTotal++
}
fmt.Printf("group policy %d\n", gTotal)
}

0 comments on commit 83dc886

Please sign in to comment.