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

transport: Change AddressStore to keep track of more dial addresses #180

Closed
1 task done
Tracked by #140
lexnv opened this issue Jul 18, 2024 · 1 comment
Closed
1 task done
Tracked by #140

transport: Change AddressStore to keep track of more dial addresses #180

lexnv opened this issue Jul 18, 2024 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@lexnv
Copy link
Collaborator

lexnv commented Jul 18, 2024

The address store keeps track of the addresses of peers, sorted internally by connection scores.
Once an address is inserted into the store, its score can never change.

We are currently losing track of dialed addresses if we already have a dial inflight:

  • fn dial_addresses(address: Multiaddr) helps us learn about a peer multiaddress
  • we completely discard the address if the peer is already Dialing Connected or Opening

Instead, we could keep track of the address:

  • insert it into the store, if not already present with score 0 (zero)
  • when we receive a successful / failure event -> update the reputation of the address (this is not present atm)
  • this should help us lower the reputation of addresses that fail to respond over multiple attempts

A few other thoughts to look over:

  • Here the store returns a sorted by score list of addresses. We collect them to a hashmap, which when iterated doesn't preserve the order of elements.

    let mut records: HashMap<_, _> = addresses
    .take(self.max_parallel_dials)
    .into_iter()
    .map(|record| (record.address().clone(), record))
    .collect();

  • The following should be changed as it is redundant

for record in addresses {
if !context.addresses.contains(record.address()) {
context.addresses.insert(record);

/// Insert new address record into [`AddressStore`] with default address score.
pub fn insert(&mut self, mut record: AddressRecord) {
if self.by_address.contains(record.address()) {
return;
}

  • Limit the number of known connections (maybe 16 would be a good start)

Tasks

Preview Give feedback
  1. enhancement
    lexnv
@lexnv
Copy link
Collaborator Author

lexnv commented Oct 28, 2024

Closed by #250

@lexnv lexnv closed this as completed Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant