mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2026-02-10 15:10:54 +00:00
Update exception type
This commit is contained in:
@ -32,7 +32,7 @@ class PeerStore(IPeerStore):
|
||||
if peer_id in self.peer_map:
|
||||
return self.peer_map[peer_id].get_protocols()
|
||||
else:
|
||||
raise Exception("peer ID not found")
|
||||
raise PeerStoreError("peer ID not found")
|
||||
|
||||
def add_protocols(self, peer_id, protocols):
|
||||
peer = self.__create_or_get_peer(peer_id)
|
||||
@ -46,7 +46,7 @@ class PeerStore(IPeerStore):
|
||||
val = self.peer_map[peer_id].get_metadata(key)
|
||||
return val
|
||||
else:
|
||||
raise Exception("peer ID not found")
|
||||
raise PeerStoreError("peer ID not found")
|
||||
|
||||
def put(self, peer_id, key, val):
|
||||
# <<?>>
|
||||
@ -66,7 +66,7 @@ class PeerStore(IPeerStore):
|
||||
if peer_id in self.peer_map:
|
||||
return self.peer_map[peer_id].get_addrs()
|
||||
else:
|
||||
raise Exception("peer ID not found")
|
||||
raise PeerStoreError("peer ID not found")
|
||||
|
||||
def clear_addrs(self, peer_id):
|
||||
# Only clear addresses if the peer is in peer map
|
||||
@ -81,3 +81,7 @@ class PeerStore(IPeerStore):
|
||||
if len(self.peer_map[key].get_addrs()) >= 1:
|
||||
output.append(key)
|
||||
return output
|
||||
|
||||
class PeerStoreError(KeyError):
|
||||
"""Raised when peer ID is not found in peer store"""
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user