don't crash when stringifying nil peerinfo

This commit is contained in:
Dmitriy Ryajov 2020-02-12 09:40:54 -05:00
parent 4faf35c52c
commit 6316b07e81
1 changed files with 5 additions and 1 deletions

View File

@ -105,9 +105,13 @@ proc publicKey*(p: PeerInfo): Option[PublicKey] {.inline.} =
result = some(p.privateKey.getKey()) result = some(p.privateKey.getKey())
proc id*(p: PeerInfo): string {.inline.} = proc id*(p: PeerInfo): string {.inline.} =
if not isNil(p):
result = p.peerId.pretty() result = p.peerId.pretty()
proc `$`*(p: PeerInfo): string = proc `$`*(p: PeerInfo): string =
if isNil(p):
return ""
result.add("PeerID: ") result.add("PeerID: ")
result.add(p.id & "\n") result.add(p.id & "\n")