<aside> 👉 This page describes the technical design of the DHT Reprovide Sweep client optimization.
</aside>
The Kademlia keyspace is vast, with as many potential pathways through it as there are keys. When referencing a "left-to-right" sweep, what we mean is this:
In essence, this sweeping method is a systematic way of iterating through all peers based on their proximity to the host itself.
Because this sweeping approach is based on the unique Kademlia identity of the node carrying it out, it offers a load balancing advantage. Specifically, it ensures that peers don't simultaneously conduct reprovides in an identical sequence (i.e., follow the same sweep order, in order to add randomness), thus preventing system bottlenecks and distributing the workload more evenly.
The Downlink interface describe how the provider module makes use of other DHT components down the stack in order to perform the (re)provide operations.
GetClosestPeers(ctx, str), returns the 20 closest peers to the provided key (in string format). The string is then hashed in order to derive the kademlia identifier.PutProvider(ctx, p, key, host), allocates a provider record on the selected peer p.PreimageWithPrefix(key, cpl), finds a preimage whose hash digest (sha256) matches the provided key with a prefix of at least cpl bits.The interface is still being discussed at ‣, but the DHT (Reprovide Sweep) needs at least the following minimal interface.
StartProvide([]cid.Cid) lets the provide module know that it should start advertising the given CIDs.StopProvide([]cid.Cid) lets the provide module know that it should stop republishing the following CIDs.ReprovideInterval reprovide interval between which all CIDs should be republished. The default value is 22h in IPFS.