Skip to content

Commit

Permalink
Fix close not being called for iterators (dydxprotocol#1891)
Browse files Browse the repository at this point in the history
  • Loading branch information
roy-dydx committed Jul 11, 2024
1 parent db2dcfd commit dbedbd7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions protocol/x/clob/keeper/process_proposer_matches_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ func (k Keeper) ResetOrderedOrderIds(
) {
prefixStore := prefix.NewStore(store, []byte(keyPrefix))
it := prefixStore.Iterator(nil, nil)
defer it.Close()
for ; it.Valid(); it.Next() {
prefixStore.Delete(it.Key())
}
Expand All @@ -153,6 +154,7 @@ func (k Keeper) ResetOrderedOrderIds(
func (k Keeper) ResetUnorderedOrderIds(ctx sdk.Context, store storetypes.KVStore, keyPrefix string) {
prefixStore := prefix.NewStore(store, []byte(keyPrefix))
it := prefixStore.Iterator(nil, nil)
defer it.Close()
for ; it.Valid(); it.Next() {
prefixStore.Delete(it.Key())
}
Expand Down Expand Up @@ -186,6 +188,7 @@ func (k Keeper) GetOrderIds(
ret := []types.OrderId{}
prefixStore := prefix.NewStore(store, []byte(keyPrefix))
it := prefixStore.Iterator(nil, nil)
defer it.Close()
for ; it.Valid(); it.Next() {
var orderId types.OrderId
k.cdc.MustUnmarshal(it.Value(), &orderId)
Expand Down
1 change: 1 addition & 0 deletions protocol/x/clob/keeper/stateful_order_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ func (k Keeper) RemoveExpiredStatefulOrders(ctx sdk.Context, blockTime time.Time
[]byte(fmt.Sprintf(types.StatefulOrdersExpirationsKeyPrefix, sdk.FormatTimeString(blockTime))),
),
)
defer it.Close()
for ; it.Valid(); it.Next() {
var orderId types.OrderId
k.cdc.MustUnmarshal(it.Value(), &orderId)
Expand Down

0 comments on commit dbedbd7

Please sign in to comment.