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:
parent
ba5273999f
commit
fc800dcbc1
1 changed files with 2 additions and 0 deletions
|
@ -60,9 +60,11 @@ func (s *service) signAndSend(r *state.MPTRoot) error {
|
||||||
|
|
||||||
sig := acc.PrivateKey().SignHashable(uint32(s.Network), r)
|
sig := acc.PrivateKey().SignHashable(uint32(s.Network), r)
|
||||||
incRoot := s.getIncompleteRoot(r.Index)
|
incRoot := s.getIncompleteRoot(r.Index)
|
||||||
|
incRoot.Lock()
|
||||||
incRoot.root = r
|
incRoot.root = r
|
||||||
incRoot.addSignature(acc.PrivateKey().PublicKey(), sig)
|
incRoot.addSignature(acc.PrivateKey().PublicKey(), sig)
|
||||||
incRoot.reverify(s.Network)
|
incRoot.reverify(s.Network)
|
||||||
|
incRoot.Unlock()
|
||||||
|
|
||||||
s.accMtx.RLock()
|
s.accMtx.RLock()
|
||||||
myIndex := s.myIndex
|
myIndex := s.myIndex
|
||||||
|
|
Loading…
Reference in a new issue