py-libp2p/peer/peerstore_interface.py

52 lines
1.3 KiB
Python
Raw Normal View History

from abc import ABC, abstractmethod
2018-10-22 03:15:53 +08:00
from .addrbook_interface import IAddrBook
from .peermetadata_interface import IPeerMetadata
class IPeerStore(ABC, IAddrBook, IPeerMetadata):
def __init__(self):
IPeerMetadata.__init__(self)
IAddrBook.__init__(self)
2018-10-22 03:15:53 +08:00
@abstractmethod
def peer_info(self, peer_id):
"""
:param peer_id: peer ID to get info for
:return: peer info object
"""
2018-10-22 03:15:53 +08:00
pass
2018-10-22 03:15:53 +08:00
@abstractmethod
def get_protocols(self, peer_id):
"""
:param peer_id: peer ID to get protocols for
2018-10-29 20:13:39 +08:00
:return: protocols (as strings)
:raise Exception: peer ID not found exception
"""
2018-10-22 03:15:53 +08:00
pass
2018-10-22 03:15:53 +08:00
@abstractmethod
def add_protocols(self, peer_id, protocols):
"""
:param peer_id: peer ID to add protocols for
:param protocols: protocols to add
2018-10-30 07:03:19 +08:00
:raise Exception: peer ID not found
"""
2018-10-22 03:15:53 +08:00
pass
2018-10-22 03:15:53 +08:00
@abstractmethod
def set_protocols(self, peer_id, protocols):
"""
:param peer_id: peer ID to set protocols for
:param protocols: protocols to set
2018-10-30 07:03:19 +08:00
:raise Exception: peer ID not found
"""
2018-10-22 03:15:53 +08:00
pass
2018-10-22 03:15:53 +08:00
@abstractmethod
def peers(self):
"""
:return: all of the peer IDs stored in peer store
"""
2018-10-22 03:15:53 +08:00
pass