Change argument name of Network.listen and blakc format

This commit is contained in:
NIC619
2019-08-01 13:25:20 +08:00
parent cd684aad9e
commit 924e965537
7 changed files with 23 additions and 35 deletions

View File

@ -58,9 +58,9 @@ class INetwork(ABC):
"""
@abstractmethod
async def listen(self, *args: Sequence[Multiaddr]) -> bool:
async def listen(self, multiaddrs: Sequence[Multiaddr]) -> bool:
"""
:param *args: one or many multiaddrs to start listening on
:param multiaddrs: one or many multiaddrs to start listening on
:return: True if at least one success
"""

View File

@ -163,12 +163,12 @@ class Swarm(INetwork):
return net_stream
async def listen(self, *args: Sequence[Multiaddr]) -> bool:
async def listen(self, multiaddrs: Sequence[Multiaddr]) -> bool:
"""
:param *args: one or many multiaddrs to start listening on
:param multiaddrs: one or many multiaddrs to start listening on
:return: true if at least one success
For each multiaddr in args
For each multiaddr
Check if a listener for multiaddr exists already
If listener already exists, continue
Otherwise:
@ -177,7 +177,7 @@ class Swarm(INetwork):
Call listener listen with the multiaddr
Map multiaddr to listener
"""
for multiaddr in args:
for multiaddr in multiaddrs:
if str(multiaddr) in self.listeners:
return True