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

kad: Fix not retrieving local records #221

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

Conversation

dmitry-markin
Copy link
Collaborator

This PR makes sure we always return a locally stored record if we have it.

This changes the existing behavior, so I am unsure if it breaks any assumptions in the client code. We should mention this breaking change in the release notes.

@dmitry-markin dmitry-markin added the bug Something isn't working label Aug 27, 2024
@dmitry-markin dmitry-markin self-assigned this Aug 27, 2024
///
/// This contains only a single result.
LocalStore(Record),

/// Records found in the network.
/// Records found in the network. This can include the locally found record.
Network(Vec<PeerRecord>),
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: Thinking out loud, since we include the local records and the records found from the network, we could try to remove the RecordsType enum all together.
Then, we could mention in the KademliaEvent::GetRecordSuccess that records fetched from the local store are populated first in the list of records ie Vec<PeerRecord> and that users can distinguish between local and network records by comparing the peer ID of the record.

Copy link
Collaborator

@lexnv lexnv left a comment

Choose a reason for hiding this comment

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

LGTM! Nice catch here!

I think it is fine to mention any breaking changes in the release notes, we'll try to be more mindful in the future, especially after stabilizing litep2p in substrate 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

2 participants