mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-19 14:34:17 +00:00
libs/db: close batch (#3397)
ClevelDB requires closing when WriteBatch is no longer needed, https://godoc.org/github.com/jmhodges/levigo#WriteBatch.Close Fixes the memory leak in https://github.com/cosmos/cosmos-sdk/issues/3842
This commit is contained in:
@@ -78,6 +78,7 @@ func (txi *TxIndex) Get(hash []byte) (*types.TxResult, error) {
|
||||
// AddBatch indexes a batch of transactions using the given list of tags.
|
||||
func (txi *TxIndex) AddBatch(b *txindex.Batch) error {
|
||||
storeBatch := txi.store.NewBatch()
|
||||
defer storeBatch.Close()
|
||||
|
||||
for _, result := range b.Ops {
|
||||
hash := result.Tx.Hash()
|
||||
@@ -109,6 +110,7 @@ func (txi *TxIndex) AddBatch(b *txindex.Batch) error {
|
||||
// Index indexes a single transaction using the given list of tags.
|
||||
func (txi *TxIndex) Index(result *types.TxResult) error {
|
||||
b := txi.store.NewBatch()
|
||||
defer b.Close()
|
||||
|
||||
hash := result.Tx.Hash()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user