use rlock instead of lock in v1 consensus engine (#483)

Co-authored-by: wjrjerome <wjrjerome@babylonchain.io>
This commit is contained in:
Banana-J 2024-03-10 09:51:05 +11:00 committed by GitHub
parent c7cb63dd09
commit 3051b2de41
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -958,9 +958,9 @@ func (x *XDPoS_v1) Seal(chain consensus.ChainReader, block *types.Block, stop <-
// that a new block should have based on the previous blocks in the chain and the
// current signer.
func (x *XDPoS_v1) CalcDifficulty(chain consensus.ChainReader, time uint64, parent *types.Header) *big.Int {
x.lock.Lock()
x.lock.RLock()
signer := x.signer
x.lock.Unlock()
x.lock.RUnlock()
return x.calcDifficulty(chain, parent, signer)
}