-
Notifications
You must be signed in to change notification settings - Fork 976
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
fix(request-response): don't keep duplicate addresses #4700
fix(request-response): don't keep duplicate addresses #4700
Conversation
Nice one. This looks to have been a wee mem leak for us. We've been doing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about using a HashSet
instead?
modified protocols/request-response/src/lib.rs
@@ -337,7 +337,7 @@ where
/// reachable addresses, if any.
connected: HashMap<PeerId, SmallVec<[Connection; 2]>>,
/// Externally managed addresses via `add_address` and `remove_address`.
- addresses: HashMap<PeerId, SmallVec<[Multiaddr; 6]>>,
+ addresses: HashMap<PeerId, HashSet<Multiaddr>>,
/// Requests that have not yet been sent and are waiting for a connection
/// to be established.
pending_outbound_requests: HashMap<PeerId, SmallVec<[RequestProtocol<TCodec>; 10]>>,
+1 for using a |
This prevents us from adding duplicates into the list of peer addresses we have.
Thanks! Can you address the clippy failure? |
Fixed the clippy lint. Is v0.53.0 set to be released soon? Or, possibly, is there a patch release that this could part of soon? Thanks for all the work! |
If you backport it to the |
Description
Resolves: #4699.
Notes & open questions
In
kad
, there is a specialAddresses
struct that might be worth reusing for this functionality.I will make further CHANGELOG edits etc if this fix is thought to be sensible.
Change checklist