Browse Source

more locking gpt

pull/8127/head
tycho garen 3 years ago
committed by M. J. Fromberger
parent
commit
8256f7099a
1 changed files with 11 additions and 2 deletions
  1. +11
    -2
      internal/consensus/state.go

+ 11
- 2
internal/consensus/state.go View File

@ -1427,7 +1427,11 @@ func (cs *State) createProposalBlock(ctx context.Context) (*types.Block, error)
return nil, nil return nil, nil
} }
proposerAddr := cs.privValidatorPubKey.Address()
proposerAddr := func() []byte {
cs.mtx.RLock()
defer cs.mtx.RUnlock()
return cs.privValidatorPubKey.Address()
}()
return cs.blockExec.CreateProposalBlock(ctx, cs.Height, cs.state, commit, proposerAddr, cs.LastCommit.GetVotes()) return cs.blockExec.CreateProposalBlock(ctx, cs.Height, cs.state, commit, proposerAddr, cs.LastCommit.GetVotes())
} }
@ -2668,7 +2672,12 @@ func (cs *State) updatePrivValidatorPubKey(rctx context.Context) error {
if err != nil { if err != nil {
return err return err
} }
cs.privValidatorPubKey = pubKey
func() {
cs.mtx.Lock()
defer cs.mtx.Unlock()
cs.privValidatorPubKey = pubKey
}()
return nil return nil
} }


Loading…
Cancel
Save