Skip to content

provider: schedule prefix length #1116

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

Open
wants to merge 1 commit into
base: provider-network-ops
Choose a base branch
from

Conversation

guillaumemichel
Copy link
Contributor

Part of #1095

Depends on #1115


The provider schedule (introduced in follow up PR) stores a mapping prefix -> timestamp, corresponding to the time at which a keyspace region represented by its prefix should be reprovided. When reproviding a region, all keys matching the region's prefix will be reprovided.

Whenever users want to provide a key with StartProviding, if no prefix of the key is in the schedule yet, we take a prefix of the key whose length is the average of the prefixes already in the schedule (assume the keyspace region has the same peers population density as the average population density in teh DHT swarm).

When the schedule is empty, we make a couple GetClosestPeers requests in order to have an approximation of the network size, helping to determine the initial prefix length to be used in the schedule.

Note that no network provide can happen before measureInitialPrefixLen has completed. measureInitialPrefixLen will block until GetClosestPeers return some peers, so it requires the node to have a connection, and the router (DHT client) to be bootstrapped. Anyway, if the DHT client isn't bootstrapped, no provide operation can succeed.

@guillaumemichel guillaumemichel requested a review from a team as a code owner July 24, 2025 10:34
This was referenced Jul 24, 2025
bytes := [32]byte{}
rand.Read(bytes[:])
for {
if s.closed() {
Copy link
Contributor

@gammazero gammazero Jul 25, 2025

Choose a reason for hiding this comment

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

Maybe move this outside the loop and have Close wait for any calls to measureInitialPrefixLen to complete.

if s.closed() {
return
}
peers, err := s.router.GetClosestPeers(context.Background(), string(bytes[:]))
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the returned err be logged or handled?

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