mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 02:42:27 +00:00
p2p/protocols: handle possible nil Peer in HasCap
This commit is contained in:
parent
425acb3016
commit
653cfcb8e6
1 changed files with 3 additions and 0 deletions
|
|
@ -427,6 +427,9 @@ func (p *Peer) Handshake(ctx context.Context, hs interface{}, verify func(interf
|
||||||
// HasCap returns true fi Peer has a capability
|
// HasCap returns true fi Peer has a capability
|
||||||
// with provided name.
|
// with provided name.
|
||||||
func (p *Peer) HasCap(capName string) (yes bool) {
|
func (p *Peer) HasCap(capName string) (yes bool) {
|
||||||
|
if p == nil || p.Peer == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
for _, c := range p.Caps() {
|
for _, c := range p.Caps() {
|
||||||
if c.Name == capName {
|
if c.Name == capName {
|
||||||
return true
|
return true
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue