Skip to content

Commit 62cd943

Browse files
authored
les: fix dead lock (#20828)
1 parent d6c5f24 commit 62cd943

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

‎les/peer.go‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -531,8 +531,6 @@ func (p *serverPeer) getTxRelayCost(amount, size int) uint64 {
531531
// HasBlock checks if the peer has a given block
532532
func (p *serverPeer) HasBlock(hash common.Hash, number uint64, hasState bool) bool {
533533
p.lock.RLock()
534-
defer p.lock.RUnlock()
535-
536534
head := p.headInfo.Number
537535
var since, recent uint64
538536
if hasState {
@@ -543,6 +541,7 @@ func (p *serverPeer) HasBlock(hash common.Hash, number uint64, hasState bool) bo
543541
recent = p.chainRecent
544542
}
545543
hasBlock := p.hasBlock
544+
p.lock.RUnlock()
546545

547546
return head >= number && number >= since && (recent == 0 || number+recent+4 > head) && hasBlock != nil && hasBlock(hash, number, hasState)
548547
}

0 commit comments

Comments
 (0)