py-libp2p/peer/peerdata_interface.py

64 lines
1.2 KiB
Python
Raw Permalink Normal View History

from abc import ABC, abstractmethod
class IPeerData(ABC):
@abstractmethod
def get_protocols(self):
"""
:return: all protocols associated with given peer
"""
2018-10-22 03:15:53 +08:00
pass
@abstractmethod
def add_protocols(self, protocols):
"""
:param protocols: protocols to add
"""
2018-10-22 03:15:53 +08:00
pass
@abstractmethod
def set_protocols(self, protocols):
"""
:param protocols: protocols to add
"""
pass
@abstractmethod
def add_addrs(self, addrs):
"""
:param addrs: multiaddresses to add
"""
2018-10-22 03:15:53 +08:00
pass
@abstractmethod
def get_addrs(self):
"""
:return: all multiaddresses
"""
2018-10-22 03:15:53 +08:00
pass
@abstractmethod
def clear_addrs(self):
"""
Clear all addresses
"""
2018-10-22 03:15:53 +08:00
pass
@abstractmethod
def put_metadata(self, key, val):
"""
:param key: key in KV pair
:param val: val to associate with key
:raise Exception: unsuccesful put
"""
2018-10-22 03:15:53 +08:00
pass
@abstractmethod
def get_metadata(self, key):
"""
:param key: key in KV pair
:return: val for key
:raise Exception: key not found
"""
2018-10-22 03:15:53 +08:00
pass