net: --connect peers are manual, as in Core - #876
Merged
reardencode merged 2 commits intoOct 4, 2026
Merged
Conversation
getpeerinfo reported a --connect peer as outbound-full-relay. Core opens every -connect address as ConnectionType::MANUAL. Both dial paths now use Manual: the tip-follow dial of the pinned targets and the redial of remembered --connect hostnames. The type is read by more than the RPC label, so the readers follow Core: - is_preferred_download counts Manual, as Core's fPreferredDownload does. Otherwise a node dialled only through --connect (or addnode, as today) never replaces a stalling headers-sync peer. - The 10 s --seednode fallback no longer runs under --connect. It fired when fewer than 2 outbound-full-relay peers were live, which manual --connect peers would never satisfy. Core never dials seednodes under -connect. - Manual peers are not held to the NODE_NETWORK service check, as in Core's ExpectServicesFromConn. Fixes reardencode#819. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The previous commit kept the 10 s seednode fallback off under --connect, but the startup dial (empty addrman) still ran. That happens when every --connect target is a hostname that does not resolve and peers.dat is empty. Both paths now share seednodes_allowed, which is false under --connect, as Core never dials seednodes under -connect. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This was referenced Oct 4, 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.
Fixes #819.
Problem
getpeerinforeports a peer dialled for--connectasoutbound-full-relay. Bitcoin Core opens every-connectaddress asConnectionType::MANUALand reports it asmanual.Fix
Both dial paths for
--connecttargets now usePeerConnType::Manual:run.rs, through a newP2PNode::follow_from_net_as(peer, typ)(follow_from_netkeepsOutboundFullRelayfor its other callers);--connecthostnames inPeerHub::redial_remembered_with.addnode addand--connecthosts now redial the same way, soremembered_redialsdrops the per-host type.The connection type feeds more than the label. For a
--connectpeer:is_preferred_download(whether a stalled headers-sync peer can be replaced)ManualaddedfPreferredDownloadcounts manual peers--seednodeaddr-fetch: the startup dial (empty addrman) and the 10 s fallback (fires below 2 live outbound-full-relay peers)--connectpeers; the startup dial ran whenever addrman was empty--connect-connectexpect_services_from_conn(NODE_NETWORKrequired)ExpectServicesFromConnis false forMANUALThe stale-tip rotation already skips
--connect, so theoutbound_full_relay_*helpers it uses are unaffected.Adding
Manualtois_preferred_downloadalso covers the second case in #819: a node whose outbound peers all come fromaddnodecould never replace a stalling headers-sync peer.Tests
node_run_p2p_short(productrun_p2p --connect) assertedconnection_type == "outbound-full-relay". It now asserts"manual".redial_same_endpoint_in_addnode_and_connect_dials_once: a--connect-only host must redial asManual.session_heartbeat_replaces_stalled_headers_sync_peer_only_with_another_preferred(renamed from..._keeps_sole_preferred_...): the sole preferred sync peer is still kept; once aManualpeer is live, the stalled sync peer is replaced.follow_dial_targets_connect_bypasses_diversityassertsfollow_dial_type. Newseednodes_are_off_under_connectcoversseednodes_allowed, the guard both seednode paths share.Each new assertion fails when its guard is reverted.
Ran locally:
cargo fmt --check,./scripts/ast-grep.sh,cargo clippy --workspace --all-targets -- -D warnings, therbitcoin-netpeers::tests, therbitcoin-noderun::tests, andnode_run_p2p_short.Not changed
is_preferred_downloadstill leaves out Core's other preferred cases (feelers, inbound peers withnoban), and it does not check that the peer can serve blocks.Literal
--connectaddresses (IP, onion, I2P, CJDNS) are dialled once at startup and not redialled after the session drops. Only--connecthostnames go into the 2 s redial loop (set_connect_hosts(config.listen.connect_dns…)inrun.rs). That is separate from #819 and unchanged here.🤖 Generated with Claude Code