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
10 changes: 5 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,11 @@ async def on_peer_connected(writer):

await network.start(port=port, host=host)

# Fund this node's wallet so it can transact in the demo
if fund > 0:
chain.state.credit_mining_reward(pk, reward=fund)
logger.info("💰 Funded %s... with %d coins", pk[:12], fund)
Comment on lines 331 to +336
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Undefined variable host will cause a NameError.

Line 331 references host, but this variable is not defined in the run_node function scope. The --host argument is parsed in main() (line 362) but never passed to run_node().

🐛 Proposed fix: Add host parameter to run_node

Update the function signature:

-async def run_node(port: int, connect_to: str | None, fund: int, datadir: str | None):
+async def run_node(port: int, connect_to: str | None, fund: int, datadir: str | None, host: str = "127.0.0.1"):

And update the call in main():

-        asyncio.run(run_node(args.port, args.connect, args.fund, args.datadir))
+        asyncio.run(run_node(args.port, args.connect, args.fund, args.datadir, args.host))
🧰 Tools
🪛 Ruff (0.15.6)

[error] 331-331: Undefined name host

(F821)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@main.py` around lines 331 - 336, The run_node function references an
undefined variable host when calling network.start(port=port, host=host); update
run_node to accept a host parameter (e.g., def run_node(..., host):) and
propagate the parsed --host value from main() into the call to run_node so
network.start receives the CLI host; ensure the run_node signature and all
callers (main) are updated to pass host and that network.start uses that host
parameter.


# Connect to a seed peer if requested
if connect_to:
try:
Expand All @@ -338,11 +343,6 @@ async def on_peer_connected(writer):
except ValueError:
logger.error("Invalid --connect format. Use host:port")

# Fund this node's wallet so it can transact in the demo
if fund > 0:
chain.state.credit_mining_reward(pk, reward=fund)
logger.info("💰 Funded %s... with %d coins", pk[:12], fund)

try:
await cli_loop(sk, pk, chain, mempool, network)
finally:
Expand Down
Loading