Skip to content
This repository has been archived by the owner on Jul 21, 2023. It is now read-only.

[WIP] feat: add option to select record #48

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

Conversation

vasco-santos
Copy link
Member

@vasco-santos vasco-santos commented Nov 2, 2018

When we intend to use arbitrary keys with no namespaces, we end up not being able to get them js-libp2p-recordselection.js#L20. However, there are use cases where we want to be able to select a specific record or provide a function to select it.

In this PR, I added an option to select the first record obtained.

@vasco-santos
Copy link
Member Author

@jacobheun

I added an option to select the first one. However, I am not sure if this is the best option for us. Maybe I should provide a function instead. What do you think?

@blakebyrnes
Copy link
Contributor

I've thought before that it would be nice to be able to return the actual record you want to re-propagate instead of an index. Use case is where you might want to merge records that different nodes have into a new entry.

@vasco-santos
Copy link
Member Author

@blakebyrnes as this is in the get, I think I did not understand your suggestion. What is the actual record that you want to re-propagate?

@blakebyrnes
Copy link
Contributor

@vasco-santos lets say you have every node in a system storing top 10 lists. When all N records come back, the "get" will compare each record to say "what is the best record" to send out as a corrected record. In cases like this type of data storage, you might actually want to merge the lists to create a new, aggregated top 10 list. It's a bit of a different use case than the bittorrent use case, but it seems like the Kad is still a valid data structure for those cases. It's just using "keys" as a convention for the content instead of as the hash of the content.

@vasco-santos
Copy link
Member Author

@vasco-santos lets say you have every node in a system storing top 10 lists. When all N records come back, the "get" will compare each record to say "what is the best record" to send out as a corrected record.

Correct

In cases like this type of data storage, you might actually want to merge the lists to create a new, aggregated top 10 list. It's a bit of a different use case than the bittorrent use case, but it seems like the Kad is still a valid data structure for those cases. It's just using "keys" as a convention for the content instead of as the hash of the content.

So, kad-dht should receive a function that selects the record to send out as a correct. But, instead of returning the index, it would return a record. This way, if the function receives a set of records, it can return one of them, or even generate a new one based on the received ones. Is that what you suggest?

@blakebyrnes
Copy link
Contributor

Yep, that's exactly what I was thinking.

@vasco-santos
Copy link
Member Author

I understand its advantages, but I don't know if I agree with that approach, as we will provide an easy way of rewriting DHT entries. Anyway, you can create a PR with your proposal, so that we can have a more clear discussion of it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants