py-libp2p/libp2p/transport/listener_interface.py

29 lines
733 B
Python
Raw Normal View History

2018-10-27 04:16:24 +08:00
from abc import ABC, abstractmethod
from typing import List
2019-08-05 11:22:44 +08:00
from multiaddr import Multiaddr
2019-08-02 16:32:33 +08:00
2018-11-13 02:02:49 +08:00
2018-10-27 04:16:24 +08:00
class IListener(ABC):
2018-10-27 06:06:56 +08:00
@abstractmethod
async def listen(self, maddr: Multiaddr) -> bool:
"""
put listener in listening mode and wait for incoming connections.
:param maddr: multiaddr of peer
2018-10-27 04:16:24 +08:00
:return: return True if successful
"""
@abstractmethod
def get_addrs(self) -> List[Multiaddr]:
"""
retrieve list of addresses the listener is listening on.
2018-10-27 04:16:24 +08:00
:return: return list of addrs
"""
@abstractmethod
async def close(self) -> None:
"""close the listener such that no more connections can be open on this
transport instance."""