From 3493b9ff7f02b34ea195893258a23c19e751c5f6 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Mon, 17 Jun 2019 14:45:14 +0300 Subject: [PATCH] Cosmetic changes requested by cheatfate --- libp2p/multiaddress.nim | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libp2p/multiaddress.nim b/libp2p/multiaddress.nim index 4aa2c7003..72c731488 100644 --- a/libp2p/multiaddress.nim +++ b/libp2p/multiaddress.nim @@ -727,9 +727,15 @@ proc init*(mtype: typedesc[MultiAddress]): MultiAddress = ## Initialize empty MultiAddress. result.data = initVBuffer() -proc tcpEndPoint*(address: IpAddress, port: Port): MultiAddress = +proc init*(mtype: typedesc[MultiAddress], + address: IpAddress, protocol: Protocol, port: Port): MultiAddress = # TODO: this can be more efficient - MultiAddress.init("/ip4/" & $address & "/tcp/" & $port) + let protocol = case protocol + of IPPROTO_TCP: "/tcp/" + of IPPROTO_UDP: "/udp/" + else: raise newException(AssertionError, + "protocol should be either TCP or UDP") + MultiAddress.init("/ip4/" & $address & protocol & $port) proc isEmpty*(ma: MultiAddress): bool = ## Returns ``true``, if MultiAddress ``ma`` is empty or non initialized.