Skip to content

Commit

Permalink
repair dead lock
Browse files Browse the repository at this point in the history
  • Loading branch information
gordon-sero committed Nov 27, 2018
1 parent 0bccf51 commit 4b4abd0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions zero/txs/zstate/state0.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type State0 struct {
g2ins_dirty map[keys.Uint256]bool
g2outs_dirty map[keys.Uint256]bool

rw *sync.RWMutex
rw *sync.RWMutex
}

func (self *State0) Tri() tri.Tri {
Expand Down Expand Up @@ -209,6 +209,10 @@ func (self *State0) Revert() {
func (state *State0) AddOut(out_o *stx.Out_O, out_z *stx.Out_Z) (root keys.Uint256) {
state.rw.Lock()
defer state.rw.Unlock()
return state.addOut(out_o, out_z)
}

func (state *State0) addOut(out_o *stx.Out_O, out_z *stx.Out_Z) (root keys.Uint256) {
os := OutState0{}
if out_o != nil {
o := *out_o
Expand Down Expand Up @@ -297,7 +301,7 @@ func (state *State0) AddStx(st *stx.T) (e error) {
}

for _, out := range st.Desc_Z.Outs {
state.AddOut(nil, &out)
state.addOut(nil, &out)
}

return
Expand Down

0 comments on commit 4b4abd0

Please sign in to comment.