29 lines
733 B
Python
29 lines
733 B
Python
from abc import ABC, abstractmethod
|
|
from typing import List
|
|
|
|
from multiaddr import Multiaddr
|
|
|
|
|
|
class IListener(ABC):
|
|
@abstractmethod
|
|
async def listen(self, maddr: Multiaddr) -> bool:
|
|
"""
|
|
put listener in listening mode and wait for incoming connections.
|
|
|
|
:param maddr: multiaddr of peer
|
|
:return: return True if successful
|
|
"""
|
|
|
|
@abstractmethod
|
|
def get_addrs(self) -> List[Multiaddr]:
|
|
"""
|
|
retrieve list of addresses the listener is listening on.
|
|
|
|
: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."""
|