Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion hathor/p2p/peer_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def __init__(self, auto_generate_keys: bool = True) -> None:
self.last_seen = inf
self.flags = set()
self._certificate_options: Optional[CertificateOptions] = None
self.source_file = None

if auto_generate_keys:
self.generate_keys()
Expand Down Expand Up @@ -169,7 +170,9 @@ def verify_signature(self, signature: bytes, data: bytes) -> bool:
def create_from_json_path(cls, path: str) -> 'PeerId':
"""Create a new PeerId from a JSON file."""
data = json.load(open(path, 'r'))
return PeerId.create_from_json(data)
peer = PeerId.create_from_json(data)
peer.source_file = path
return peer

@classmethod
def create_from_json(cls, data: dict[str, Any]) -> 'PeerId':
Expand Down