Browse Source
Merge pull request #20 from zixuanzh/peer-cleanup
Removing notion of context from peerstore
pull/25/head
ZX
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
9 additions and
9 deletions
-
peer/addrbook_interface.py
-
peer/peermetadata_interface.py
-
peer/peerstore.py
-
peer/peerstore_interface.py
|
@ -2,8 +2,8 @@ from abc import ABC, abstractmethod |
|
|
|
|
|
|
|
|
class IAddrBook(ABC): |
|
|
class IAddrBook(ABC): |
|
|
|
|
|
|
|
|
def __init__(self, context): |
|
|
def __init__(self): |
|
|
self.context = context |
|
|
pass |
|
|
|
|
|
|
|
|
@abstractmethod |
|
|
@abstractmethod |
|
|
def add_addr(self, peer_id, addr, ttl): |
|
|
def add_addr(self, peer_id, addr, ttl): |
|
|
|
@ -2,8 +2,8 @@ from abc import ABC, abstractmethod |
|
|
|
|
|
|
|
|
class IPeerMetadata(ABC): |
|
|
class IPeerMetadata(ABC): |
|
|
|
|
|
|
|
|
def __init__(self, context): |
|
|
def __init__(self): |
|
|
self.context = context |
|
|
pass |
|
|
|
|
|
|
|
|
@abstractmethod |
|
|
@abstractmethod |
|
|
def get(self, peer_id, key): |
|
|
def get(self, peer_id, key): |
|
|
|
@ -3,8 +3,8 @@ from .peerdata import PeerData |
|
|
|
|
|
|
|
|
class PeerStore(IPeerStore): |
|
|
class PeerStore(IPeerStore): |
|
|
|
|
|
|
|
|
def __init__(self, context): |
|
|
def __init__(self): |
|
|
IPeerStore.__init__(self, context) |
|
|
IPeerStore.__init__(self) |
|
|
self.peer_map = {} |
|
|
self.peer_map = {} |
|
|
|
|
|
|
|
|
def __create_or_get_peer(self, peer_id): |
|
|
def __create_or_get_peer(self, peer_id): |
|
|
|
@ -4,9 +4,9 @@ from .peermetadata_interface import IPeerMetadata |
|
|
|
|
|
|
|
|
class IPeerStore(ABC, IAddrBook, IPeerMetadata): |
|
|
class IPeerStore(ABC, IAddrBook, IPeerMetadata): |
|
|
|
|
|
|
|
|
def __init__(self, context): |
|
|
def __init__(self): |
|
|
IPeerMetadata.__init__(self, context) |
|
|
IPeerMetadata.__init__(self) |
|
|
IAddrBook.__init__(self, context) |
|
|
IAddrBook.__init__(self) |
|
|
|
|
|
|
|
|
@abstractmethod |
|
|
@abstractmethod |
|
|
def peer_info(self, peer_id): |
|
|
def peer_info(self, peer_id): |
|
|