Skip to content

Commit

Permalink
les: fix dead lock (ethereum#20828)
Browse files Browse the repository at this point in the history
  • Loading branch information
rjl493456442 authored and Or Neeman committed Nov 18, 2020
1 parent 32a6af1 commit 19bf7b8
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions les/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -611,8 +611,6 @@ func (p *serverPeer) getTxRelayCost(amount, size int) uint64 {
// HasBlock checks if the peer has a given block
func (p *serverPeer) HasBlock(hash common.Hash, number *uint64, hasState bool) bool {
p.lock.RLock()
defer p.lock.RUnlock()

head := p.headInfo.Number
var since, recent uint64
if hasState {
Expand All @@ -623,6 +621,7 @@ func (p *serverPeer) HasBlock(hash common.Hash, number *uint64, hasState bool) b
recent = p.chainRecent
}
hasBlock := p.hasBlock
p.lock.RUnlock()

// If number is not provided then we return an optimistic yet possible false positive
if number == nil {
Expand Down

0 comments on commit 19bf7b8

Please sign in to comment.