Skip to content

Release 0.7.1: restart a DHT that stays empty - #127

Merged
nexxeln merged 2 commits into
mainfrom
fix/dht-watchdog
Nov 29, 2026
Merged

nexxeln merged 2 commits into
mainfrom
fix/dht-watchdog

Conversation

@nexxeln

@nexxeln nexxeln commented Nov 29, 2026

Copy link
Copy Markdown
Owner

An engine that ran for days through network changes (Wi-Fi, a phone hotspot, Cloudflare WARP on and off) lost every DHT node and never bootstrapped again. dht.state shrank to its node ids alone, and any magnet that leans on the DHT failed with "No peer sent its file list" or "No data arrived": even Ubuntu 26.10 by bare infohash timed out after 60 s, while the same magnet with a tracker listed its files in 6 s. Restarting the engine fixed it at once.

The engine now counts the routing table's nodes every minute (Session::dht_nodes, from session_state). After 2 minutes empty it turns the DHT off and on (Session::restart_dht), which adds the bootstrap routers again, and it waits twice as long after each restart that leaves the table empty, up to 30 minutes, so a machine that is offline does not churn.

Tested:

  • cargo test --workspace: all pass except the_engine_keeps_trying_the_home_network_while_another_program_holds_its_port, which passed on its own twice and does not touch the DHT.
  • New tests: a DHT that reaches no router counts 0 nodes and runs again after a restart (engine); the restart timing, 2, then 4, then 8 more minutes, reset by a node and capped at 30 (daemon).
  • Live, on the public DHT: 209 nodes after 20 s, 0 right after restart_dht, 232 twenty seconds later.

Sets the version to 0.7.1.

🤖 Generated with Claude Code

An engine that ran for 11 days through Wi-Fi, hotspot and VPN changes ended up with no DHT nodes
and never bootstrapped again: dht.state held only node ids, and a magnet with just an infohash, even
Ubuntu's, timed out with "no peer sent its file list" until the engine restarted.

The engine now counts the routing table's nodes every minute. Once it has been empty for 2 minutes,
it turns the DHT off and on, which adds the bootstrap routers again, and waits twice as long after
each restart that finds it still empty, up to 30 minutes, so an offline machine does not churn.
@nexxeln
nexxeln merged commit cdb7f40 into main Nov 29, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant