Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update storage discontinue param's default value #286

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions x/storage/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -1455,28 +1455,28 @@ func (k Keeper) appendDiscontinueBucketIds(ctx sdk.Context, timestamp int64, buc
store.Set(key, k.cdc.MustMarshal(&types.Ids{Id: bucketIds}))
}

func (k Keeper) DeleteDiscontinueBucketsUntil(ctx sdk.Context, timestamp int64, maxObjectsToDelete uint64) (uint64, error) {
func (k Keeper) DeleteDiscontinueBucketsUntil(ctx sdk.Context, timestamp int64, maxToDelete uint64) (uint64, error) {
store := ctx.KVStore(k.storeKey)
key := types.GetDiscontinueBucketIdsKey(timestamp)
iterator := store.Iterator(types.DiscontinueBucketIdsPrefix, storetypes.InclusiveEndBytes(key))
defer iterator.Close()

deleted := uint64(0)
for ; iterator.Valid(); iterator.Next() {
if deleted >= maxObjectsToDelete {
if deleted >= maxToDelete {
break
}
var ids types.Ids
k.cdc.MustUnmarshal(iterator.Value(), &ids)

left := make([]types.Uint, 0)
for _, id := range ids.Id {
if deleted >= maxObjectsToDelete {
if deleted >= maxToDelete {
left = append(left, id)
continue
}

bucketDeleted, objectDeleted, err := k.ForceDeleteBucket(ctx, id, maxObjectsToDelete-deleted)
bucketDeleted, objectDeleted, err := k.ForceDeleteBucket(ctx, id, maxToDelete-deleted)
if err != nil {
ctx.Logger().Error("force delete bucket error", "err", err)
return deleted, err
Expand All @@ -1485,6 +1485,8 @@ func (k Keeper) DeleteDiscontinueBucketsUntil(ctx sdk.Context, timestamp int64,

if !bucketDeleted {
left = append(left, id)
} else {
deleted++
}
}
if len(left) > 0 {
Expand Down
2 changes: 1 addition & 1 deletion x/storage/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const (
DefaultDiscontinueObjectMax uint64 = math.MaxUint64
DefaultDiscontinueBucketMax uint64 = math.MaxUint64
DefaultDiscontinueConfirmPeriod int64 = 604800 // 7 days (in second)
DefaultDiscontinueDeletionMax uint64 = 10000
DefaultDiscontinueDeletionMax uint64 = 100
DefaultStalePolicyCleanupMax uint64 = 200

DefaultMirrorBucketRelayerFee = "250000000000000" // 0.00025
Expand Down