-
-
Notifications
You must be signed in to change notification settings - Fork 16
Fix 7 critical bugs preventing node from running correctly #32
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
Changes from all commits
08515cc
109c7e8
c673b28
46451cb
8dc2d91
7b00276
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,7 +19,7 @@ class P2PNetwork: | |
| } | ||
| """ | ||
|
|
||
| def __init__(self, handler_callback=None): | ||
| def __init__(self, handler_callback=None) -> None: | ||
| self._handler_callback = None | ||
| if handler_callback is not None: | ||
| self.register_handler(handler_callback) | ||
|
|
@@ -44,7 +44,7 @@ async def stop(self): | |
| if hasattr(self.pubsub, method_name): | ||
| shutdown_meth = getattr(self.pubsub, method_name) | ||
| break | ||
|
|
||
| if shutdown_meth: | ||
| import asyncio | ||
| res = shutdown_meth() | ||
|
|
@@ -83,6 +83,9 @@ async def handle_message(self, msg): | |
| """ | ||
| Callback when a p2p message is received. | ||
| """ | ||
| if not callable(self._handler_callback): | ||
| logger.debug("Network: No handler callback set, ignoring message") | ||
| return | ||
|
Comment on lines
+86
to
+88
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Redundant check creates unreachable code. The early guard at lines 86-88 returns if ♻️ Suggested simplification try:
- if self._handler_callback:
- await self._handler_callback(data)
- else:
- logger.warning("Network Error: No handler_callback registered")
+ await self._handler_callback(data)
except Exception:
logger.exception("Error in network handler callback for data: %s", data)Also applies to: 116-119 🤖 Prompt for AI Agents |
||
|
|
||
| try: | ||
| if not hasattr(msg, "data"): | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.