Skip to content

Conversation

@hanabi1224
Copy link
Contributor

@hanabi1224 hanabi1224 commented Dec 8, 2025

Description

This PR tries to port smart dialing logic from go-libp2p
https://github.com/libp2p/go-libp2p/blob/v0.45.0/p2p/net/swarm/dial_ranker.go
libp2p/go-libp2p#2260

Notes & open questions

Change checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • A changelog entry has been made in the appropriate crates

@hanabi1224 hanabi1224 force-pushed the smart-dialing branch 2 times, most recently from 7eb74b9 to 3a39fee Compare December 8, 2025 16:22
@hanabi1224 hanabi1224 marked this pull request as ready for review December 10, 2025 11:04
const PUBLIC_OTHER_DELAY: Duration = Duration::from_millis(1000);
const PRIVATE_OTHER_DELAY: Duration = Duration::from_millis(100);

pub(crate) type DialRanker = fn(Vec<Multiaddr>) -> Vec<(Multiaddr, Option<Duration>)>;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we consider using a closure here instead of a fn?

It would preserve the current behaviour and also allow dial rankings to incorporate runtime state if needed. Similar patterns are used for Swarm and SwarmBuilder.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea! Changed DailRanker to a closure trait object

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.

2 participants