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

get: Make device peer vector a map #25

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ernestask
Copy link
Collaborator

Currently, peers in a device are stored as a vector, which requires
iterating to find a peer by its public key, so this commit changes it to
be a hash map.

Currently, peers in a device are stored as a vector, which requires
iterating to find a peer by its public key, so this commit changes it to
be a hash map.
@gluxon gluxon self-assigned this Jun 4, 2022
@gluxon
Copy link
Owner

gluxon commented Jun 11, 2022

I've had a bit of difficulty deciding whether the types returned from this library should be easy to use or reflective of the raw Netlink responses. Although a map is certainly more useful, the original intention was to mimic the raw response.

I think there's good arguments both ways. Is the primary advantage of returning a map directly to avoid a O(n) passthrough on the Vec<Peers> after the response is serialized? Or are there other advantages I'm forgetting?

@ernestask
Copy link
Collaborator Author

I guess you do have a point here, because my use case is holding a map of peers at runtime for constant-time access. Serialization and deserialization is more a happy accident. The peculiarity of largely reimplementing the data structures with one field having a different type (and, of course, the reimplemented serialization code) made me want to propose this.

@gluxon gluxon removed their assignment Aug 8, 2023
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