fix: migrate NAT-friendly quote selection and process exit fix#4
Merged
mickvandijke merged 2 commits intoWithAutonomi:mainfrom Mar 25, 2026
Merged
Conversation
The previous quote collection used FuturesUnordered and took the first 5 responses. This systematically excluded nodes behind NAT because cloud nodes always respond faster, causing the NATed node's quote to arrive 6th and be dropped — even when it was the 2nd closest peer by XOR distance. Now collects all quote responses, sorts by XOR distance to the chunk address, and takes the closest REQUIRED_QUOTES (5) peers. This ensures deterministic, distance-based placement where every reachable node gets a fair chance regardless of network latency. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The tokio runtime's graceful shutdown blocks indefinitely on open QUIC connections and pending background tasks (DHT, keep-alive). Restructure main() to call std::process::exit() after all work completes, for both success (exit 0) and error (exit 1) paths. All data is persisted/printed before the exit point, so nothing is lost. This is essential for continuous upload workflows where the uploader script needs the ant process to exit promptly so the next upload can begin. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
mickvandijke
approved these changes
Mar 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
REQUIRED_QUOTESpeers. This prevents systematic exclusion of nodes behind NAT whose responses arrive slower than cloud nodes.main()to callstd::process::exit()after all work completes, preventing indefinite hangs from open QUIC connections and pending background tasks during tokio runtime shutdown.Both fixes are migrated from
saorsa-clientcommitsa7374ee6and45a8c45b.Test plan
cargo checkpassescargo clippy --all-targets --all-features -- -D warningspassescargo fmt --all -- --checkpassesantCLI exits promptly after upload completes🤖 Generated with Claude Code