Skip to content

Commit

Permalink
refactor: keep batch.Close error handle logic consistance
Browse files Browse the repository at this point in the history
  • Loading branch information
lfz941 committed Sep 20, 2024
1 parent 465ca23 commit 80dda92
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 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("error on batch close", "err", err)
}
}()

if cInfo != nil {
Expand Down
5 changes: 3 additions & 2 deletions store/v2/commitment/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,9 @@ func (m *MetadataStore) deleteRemovedStoreKeys(version uint64, removeStore func(

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

0 comments on commit 80dda92

Please sign in to comment.