Skip to content

Kademlia: custom K_VALUE #5875

Closed
Closed
@ShahakShama

Description

@ShahakShama

Description

In Kademlia, right now, K_VALUE is a constant set to 20. We want the ability to create a Kademlia behaviour with other values

Motivation

When using Kademlia for discovery, the K_VALUE determines how many peers will I be able to directly dial to. This value changes based on use case: How many peers do I have in total in the network? How well connected do I want them to be?
(For example, for a gossipsub network where I set mesh_n to be higher than 20, I want to be connected to more than 20 peers in order to reduce the amount of hops every message will have)

Requirements

Kademlia's Config should have a new method called set_k_value() which will change the k value used throughout the code. The default will remain 20.

This change can be non-breaking. We'll just add this new function to the Config struct and keep the K_VALUE constant in the code while marking it as deprecated. The constant still has the meaning of: "the default value for K"

Open questions

No response

Are you planning to do it yourself in a pull request?

Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions