2018-10-21 04:55:37 +08:00
|
|
|
from abc import ABC, abstractmethod
|
|
|
|
|
|
|
|
class IPeerData(ABC):
|
|
|
|
|
2018-11-03 04:16:46 +08:00
|
|
|
@abstractmethod
|
2018-10-21 04:55:37 +08:00
|
|
|
def get_protocols(self):
|
2018-11-03 04:16:46 +08:00
|
|
|
"""
|
|
|
|
:return: all protocols associated with given peer
|
|
|
|
"""
|
2018-10-22 03:15:53 +08:00
|
|
|
pass
|
2018-10-21 04:55:37 +08:00
|
|
|
|
2018-11-03 04:16:46 +08:00
|
|
|
@abstractmethod
|
2018-10-21 04:55:37 +08:00
|
|
|
def add_protocols(self, protocols):
|
2018-11-03 04:16:46 +08:00
|
|
|
"""
|
|
|
|
:param protocols: protocols to add
|
|
|
|
"""
|
2018-10-22 03:15:53 +08:00
|
|
|
pass
|
2018-10-21 04:55:37 +08:00
|
|
|
|
2018-11-03 04:16:46 +08:00
|
|
|
@abstractmethod
|
|
|
|
def set_protocols(self, protocols):
|
|
|
|
"""
|
|
|
|
:param protocols: protocols to add
|
|
|
|
"""
|
|
|
|
pass
|
|
|
|
|
|
|
|
@abstractmethod
|
2018-10-21 04:55:37 +08:00
|
|
|
def add_addrs(self, addrs):
|
2018-11-03 04:16:46 +08:00
|
|
|
"""
|
|
|
|
:param addrs: multiaddresses to add
|
|
|
|
"""
|
2018-10-22 03:15:53 +08:00
|
|
|
pass
|
2018-10-21 04:55:37 +08:00
|
|
|
|
2018-11-03 04:16:46 +08:00
|
|
|
@abstractmethod
|
2018-10-21 04:55:37 +08:00
|
|
|
def get_addrs(self):
|
2018-11-03 04:16:46 +08:00
|
|
|
"""
|
|
|
|
:return: all multiaddresses
|
|
|
|
"""
|
2018-10-22 03:15:53 +08:00
|
|
|
pass
|
2018-10-21 04:55:37 +08:00
|
|
|
|
2018-11-03 04:16:46 +08:00
|
|
|
@abstractmethod
|
2018-10-21 04:55:37 +08:00
|
|
|
def clear_addrs(self):
|
2018-11-03 04:16:46 +08:00
|
|
|
"""
|
|
|
|
Clear all addresses
|
|
|
|
"""
|
2018-10-22 03:15:53 +08:00
|
|
|
pass
|
2018-10-21 04:55:37 +08:00
|
|
|
|
2018-11-03 04:16:46 +08:00
|
|
|
@abstractmethod
|
2018-10-21 04:55:37 +08:00
|
|
|
def put_metadata(self, key, val):
|
2018-11-03 04:16:46 +08:00
|
|
|
"""
|
|
|
|
: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
|
2018-10-21 04:55:37 +08:00
|
|
|
|
2018-11-03 04:16:46 +08:00
|
|
|
@abstractmethod
|
2018-10-21 04:55:37 +08:00
|
|
|
def get_metadata(self, key):
|
2018-11-03 04:16:46 +08:00
|
|
|
"""
|
|
|
|
:param key: key in KV pair
|
|
|
|
:return: val for key
|
|
|
|
:raise Exception: key not found
|
|
|
|
"""
|
2018-10-22 03:15:53 +08:00
|
|
|
pass
|