From 653cfcb8e6c71f00ba0e79a2b28bbaa4a1179069 Mon Sep 17 00:00:00 2001 From: Janos Guljas Date: Tue, 22 Jan 2019 12:40:15 +0100 Subject: [PATCH] p2p/protocols: handle possible nil Peer in HasCap --- p2p/protocols/protocol.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/p2p/protocols/protocol.go b/p2p/protocols/protocol.go index 1ecac2ffe4..4899b35cfb 100644 --- a/p2p/protocols/protocol.go +++ b/p2p/protocols/protocol.go @@ -427,6 +427,9 @@ func (p *Peer) Handshake(ctx context.Context, hs interface{}, verify func(interf // HasCap returns true fi Peer has a capability // with provided name. func (p *Peer) HasCap(capName string) (yes bool) { + if p == nil || p.Peer == nil { + return false + } for _, c := range p.Caps() { if c.Name == capName { return true