From 15aa0deb5abd995a05a45f085cc092094e392c6f Mon Sep 17 00:00:00 2001 From: Gui Iribarren Date: Tue, 19 Sep 2023 16:44:52 +0200 Subject: [PATCH] state: Save now defers v.tx.Unlock() until the end --- vochain/state/state.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vochain/state/state.go b/vochain/state/state.go index 6ef2d5307..3cb98a019 100644 --- a/vochain/state/state.go +++ b/vochain/state/state.go @@ -404,6 +404,7 @@ func (v *State) Save() ([]byte, error) { // Note that we need to commit the tx after calling listeners, because // the listeners may need to get the previous (not committed) state. v.tx.Lock() + defer v.tx.Unlock() err := func() error { var err error if err := v.tx.Commit(height); err != nil { @@ -414,7 +415,6 @@ func (v *State) Save() ([]byte, error) { } return nil }() - v.tx.Unlock() if err != nil { return nil, err }