Skip to content

fix: missing PeerId.source_file #1007

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 25, 2024
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
Loading