From e42c50c12344168c36296e7d0f3493822ce6fce2 Mon Sep 17 00:00:00 2001 From: Alessio Treglia Date: Mon, 20 Jul 2020 13:05:29 +0200 Subject: [PATCH] x/staking: add call to iterator Close() method (#6794) Original pull request: #6791 --- CHANGELOG.md | 1 + x/staking/keeper/delegation.go | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1bca6ce8cb82..00a3a19b0441 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (client) [\#5585](https://github.com/cosmos/cosmos-sdk/pull/5585) `CLIContext` additions: * Introduce `QueryABCI` that returns the full `abci.ResponseQuery` with inclusion Merkle proofs. * Added `prove` flag for Merkle proof verification. +* (x/staking) [\#6791)](https://github.com/cosmos/cosmos-sdk/pull/6791) Close {UBDQueue,RedelegationQueu}Iterator once used. ### API Breaking Changes diff --git a/x/staking/keeper/delegation.go b/x/staking/keeper/delegation.go index 219beef71271..53d778c14912 100644 --- a/x/staking/keeper/delegation.go +++ b/x/staking/keeper/delegation.go @@ -258,6 +258,8 @@ func (k Keeper) DequeueAllMatureUBDQueue(ctx sdk.Context, store := ctx.KVStore(k.storeKey) // gets an iterator for all timeslices from time 0 until the current Blockheader time unbondingTimesliceIterator := k.UBDQueueIterator(ctx, ctx.BlockHeader().Time) + defer unbondingTimesliceIterator.Close() + for ; unbondingTimesliceIterator.Valid(); unbondingTimesliceIterator.Next() { timeslice := []types.DVPair{} value := unbondingTimesliceIterator.Value() @@ -445,6 +447,8 @@ func (k Keeper) DequeueAllMatureRedelegationQueue(ctx sdk.Context, currTime time store := ctx.KVStore(k.storeKey) // gets an iterator for all timeslices from time 0 until the current Blockheader time redelegationTimesliceIterator := k.RedelegationQueueIterator(ctx, ctx.BlockHeader().Time) + defer redelegationTimesliceIterator.Close() + for ; redelegationTimesliceIterator.Valid(); redelegationTimesliceIterator.Next() { timeslice := []types.DVVTriplet{} value := redelegationTimesliceIterator.Value()