stateroot: protect incomplete root manipulations in signAndSend

We're modifying it here, so there can be a race between this method and
AddSignature().
This commit is contained in:
Roman Khimov 2021-05-06 21:53:34 +03:00
parent ba5273999f
commit fc800dcbc1

View file

@ -60,9 +60,11 @@ func (s *service) signAndSend(r *state.MPTRoot) error {
sig := acc.PrivateKey().SignHashable(uint32(s.Network), r)
incRoot := s.getIncompleteRoot(r.Index)
incRoot.Lock()
incRoot.root = r
incRoot.addSignature(acc.PrivateKey().PublicKey(), sig)
incRoot.reverify(s.Network)
incRoot.Unlock()
s.accMtx.RLock()
myIndex := s.myIndex