2018-10-21 04:55:15 +08:00
|
|
|
from abc import ABC, abstractmethod
|
2019-08-01 06:00:12 +08:00
|
|
|
from typing import Any
|
2019-07-27 16:27:01 +08:00
|
|
|
|
2019-08-01 06:00:12 +08:00
|
|
|
from .id import ID
|
2018-10-21 04:55:15 +08:00
|
|
|
|
2019-01-10 02:38:56 +08:00
|
|
|
|
2018-10-21 04:55:15 +08:00
|
|
|
class IPeerMetadata(ABC):
|
2019-07-27 16:27:01 +08:00
|
|
|
def __init__(self) -> None:
|
2018-10-27 03:51:25 +08:00
|
|
|
pass
|
2018-10-21 04:55:15 +08:00
|
|
|
|
2018-10-22 03:15:53 +08:00
|
|
|
@abstractmethod
|
2019-07-30 15:31:02 +08:00
|
|
|
def get(self, peer_id: ID, key: str) -> Any:
|
2018-10-22 03:15:53 +08:00
|
|
|
"""
|
|
|
|
:param peer_id: peer ID to lookup key for
|
|
|
|
:param key: key to look up
|
2018-10-30 07:03:19 +08:00
|
|
|
:return: value at key for given peer
|
|
|
|
:raise Exception: peer ID not found
|
2018-10-21 04:55:15 +08:00
|
|
|
"""
|
|
|
|
|
2018-10-22 03:15:53 +08:00
|
|
|
@abstractmethod
|
2019-07-30 15:31:02 +08:00
|
|
|
def put(self, peer_id: ID, key: str, val: Any) -> None:
|
2018-10-22 03:15:53 +08:00
|
|
|
"""
|
|
|
|
:param peer_id: peer ID to lookup key for
|
|
|
|
:param key: key to associate with peer
|
|
|
|
:param val: value to associated with key
|
2018-10-30 07:03:19 +08:00
|
|
|
:raise Exception: unsuccessful put
|
2018-10-21 04:55:15 +08:00
|
|
|
"""
|