Skip to content
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

Clarify meaning of is_unreachable #3023

Merged
merged 3 commits into from
Nov 23, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion bin/light-base/src/network_service/tasks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ pub(super) async fn connection_task<TPlat: Platform>(
guarded.network.pending_outcome_err(
start_connect.id,
err.map_or(false, |err| err.is_bad_addr),
); // TODO: should pass a proper value for `is_unreachable`, but an error is sometimes returned despite a timeout https://github.com/paritytech/smoldot/issues/1531
);

for chain_index in 0..guarded.network.num_chains() {
guarded
Expand Down
11 changes: 5 additions & 6 deletions src/network/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -559,16 +559,15 @@ where
/// See also [`ChainNetwork::pending_outcome_ok_single_stream`] and
/// [`ChainNetwork::pending_outcome_ok_multi_stream`].
///
/// `is_unreachable` should be `true` if the address is invalid or unreachable and should
/// thus never be attempted again unless it is re-discovered. It should be `false` if the
/// address might only be temporarily unreachable, such as because of a timeout. If `false`
/// is passed, the address might be attempted again in the future.
/// `is_bad_address` should be `true` if the address is invalid or definitely unreachable and
/// should thus never be attempted again unless it is re-discovered. If `false` is passed, the
/// address might be attempted again in the future.
///
/// # Panic
///
/// Panics if the [`PendingId`] is invalid.
///
pub fn pending_outcome_err(&mut self, id: PendingId, is_unreachable: bool) {
pub fn pending_outcome_err(&mut self, id: PendingId, is_bad_address: bool) {
let (expected_peer_id, multiaddr, _) = self.pending_ids.get(id.0).unwrap();
let multiaddr = multiaddr.clone(); // Solves borrowck issues.

Expand Down Expand Up @@ -604,7 +603,7 @@ where
// Updates the addresses book.
if let Some(KBucketsPeer { addresses, .. }) = self.kbuckets_peers.get_mut(&expected_peer_id)
{
if is_unreachable {
if is_bad_address {
// Do not remove last remaining address, in order to prevent the addresses
// list from ever becoming empty.
debug_assert!(!addresses.is_empty());
Expand Down