Skip to content

Commit

Permalink
core:world_state.go dispose txStates
Browse files Browse the repository at this point in the history
  • Loading branch information
fengzi committed Mar 17, 2018
1 parent f86dfd8 commit 17d0813
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
13 changes: 13 additions & 0 deletions core/state/world_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -621,18 +621,31 @@ func (ws *worldState) Begin() error {

func (ws *worldState) Commit() error {
if err := ws.states.Commit(); err != nil {
ws.Dispose()
return err
}
ws.Dispose()
return nil
}

func (ws *worldState) RollBack() error {
if err := ws.states.RollBack(); err != nil {
ws.Dispose()
return err
}
ws.Dispose()
return nil
}

func (ws *worldState) Dispose() {
ws.txStates.Range(func(k, v interface{}) bool {
txwd := v.(*txWorldState)
txwd.states = nil
return true
})
ws.txStates = nil
}

type txWorldState struct {
*states
txid interface{}
Expand Down
3 changes: 2 additions & 1 deletion storage/rocks_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ func (storage *RocksStorage) Flush() error {
}

wb := gorocksdb.NewWriteBatch()
defer wb.Clear()
defer wb.Destroy()

for _, opt := range storage.batchOpts {
if opt.deleted {
wb.Delete(opt.key)
Expand Down

0 comments on commit 17d0813

Please sign in to comment.