-
Notifications
You must be signed in to change notification settings - Fork 20
Description
The address store is used in two places for keeping track of healthy addresses:
- Transport manager (the source of truth for dialing)
- Kademlia address store (eventually consistent store, for responding efficiently on FIND_NODE queries)
litep2p/src/protocol/libp2p/kademlia/types.rs
Lines 256 to 257 in 954d01b
/// Known addresses of peer. | |
pub(super) address_store: AddressStore, |
The address store sorts the containing addresses of the peer every time it wants to respond to FIND_NODE queries:
litep2p/src/protocol/libp2p/kademlia/types.rs
Lines 287 to 290 in 954d01b
/// Returns the addresses of the peer. | |
pub fn addresses(&self) -> Vec<Multiaddr> { | |
self.address_store.addresses(MAX_ADDRESSES) | |
} |
This leads to ~5-7% worse CPU performance. Instead, investigate if we can live with an address store which contains 3 buckets: successfully dialed, undialed, and failure to dial. This should improve the performance as we'll not have to do any sorting.
Another possible revenue source to follow: we could return an iterator over references of addresses (and possibly avoid 1 extra allocation).