Skip to content

Commit

Permalink
fix: using defer to ensure close db handle
Browse files Browse the repository at this point in the history
  • Loading branch information
yukionfire committed Jul 17, 2024
1 parent 49bc189 commit 94d685c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion store/v2/commitment/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ func (m *MetadataStore) flushCommitInfo(version uint64, cInfo *proof.CommitInfo)
}

batch := m.kv.NewBatch()
defer batch.Close()
cInfoKey := []byte(fmt.Sprintf(commitInfoKeyFmt, version))
value, err := cInfo.Marshal()
if err != nil {
Expand All @@ -87,7 +88,7 @@ func (m *MetadataStore) flushCommitInfo(version uint64, cInfo *proof.CommitInfo)
if err := batch.WriteSync(); err != nil {
return err
}
return batch.Close()
return nil
}

func (m *MetadataStore) deleteCommitInfo(version uint64) error {
Expand Down

0 comments on commit 94d685c

Please sign in to comment.