p2p/protocols: handle possible nil Peer in HasCap

This commit is contained in:
Janos Guljas 2019-01-22 12:40:15 +01:00
parent 425acb3016
commit 653cfcb8e6

View file

@ -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