Skip to content

Commit

Permalink
refactor: keep batch.Close error handle logic consistance (#21812)
Browse files Browse the repository at this point in the history
  • Loading branch information
lfz941 authored Sep 26, 2024
1 parent 89d96e8 commit 648ef5f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 3 additions & 1 deletion store/rootmulti/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -1147,7 +1147,9 @@ func (rs *Store) flushMetadata(db corestore.KVStoreWithBatch, version int64, cIn
rs.logger.Debug("flushing metadata", "height", version)
batch := db.NewBatch()
defer func() {
_ = batch.Close()
if err := batch.Close(); err != nil {
rs.logger.Error("call flushMetadata error on batch close", "err", err)
}
}()

if cInfo != nil {
Expand Down
5 changes: 2 additions & 3 deletions store/v2/commitment/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package commitment

import (
"bytes"
"errors"
"fmt"

corestore "cosmossdk.io/core/store"
Expand Down Expand Up @@ -158,9 +159,7 @@ func (m *MetadataStore) deleteRemovedStoreKeys(version uint64, removeStore func(

batch := m.kv.NewBatch()
defer func() {
if berr := batch.Close(); berr != nil {
err = berr
}
err = errors.Join(err, batch.Close())
}()
for _, storeKey := range removedStoreKeys {
if err := removeStore(storeKey, version); err != nil {
Expand Down

0 comments on commit 648ef5f

Please sign in to comment.