Go-libp2p-kad-dht 0.3.0 released with breaking changes

This release introduces some significant improvements (and a few breaking changes) to the logic around refreshing the routing tables (previously known as “bootstrapping”).

This was previously called “bootstrapping” but bootstrapping and refreshing the routing tables are two separate operations:

  • Bootstrapping is the process of connecting to a set of initial nodes to join the DHT. The DHT doesn’t currently perform any bootstrapping internally.
  • Refreshing is the process of filling out the routing table.

Behavior Changes:

  • The DHT now automatically starts refreshing the routing table as soon as it’s started so there’s no need to call Bootstrap.
  • The DHT will now refresh the routing table as soon as it sees a new peer as long as we have less than 4 peers in the routing table. This helps us quickly re-build the routing table if we disconnect then reconnect to the network.
  • The DHT now implements the refreshing algorithm described in the Kademlia paper. This should ensure that the routing table remains full.

Breaking API Changes:

  • The global NumBootstrapQueries has been removed. The official
  • The BootstrapWithConfig function has been removed as bootstrapping is now started immediately after constructing the DHT.
  • The global BootstrapConfig type has been removed along with BootstrapWithConfig:
    • The config options changed as the old ones didn’t make sense given the new algorithm.
    • The config options can now be passed in via the constructor using functional arguments.
  • BootstrapSelf has been removed. This was not an effective way to bootstrap the DHT and all users should just call Refresh().
  • BootstrapRandom has been removed in favor of Refresh().
  • BootstrapOnce has been removed in favor of Refresh().
  • The global DefaultBootstrapConfig has been removed along with the BootstrapConfig type.

Upgrade Notes:

  • You no longer need to call any of the Bootstrap methods. If you want force the DHT to fill out its routing table, call Refresh().
  • You can now configure routing table refreshing using the following options when constructing the DHT:
    • DisableAutoRefresh - Never automatically refresh the routing tables. If you pass this, you’ll need to manually invoke Refresh() as needed.
    • RoutingTableRefreshPeriod - How frequently we should refresh the routing table.
    • RoutingTableRefreshQueryTimeout - how long to run each query during the refresh process before timing it out.

Thanks: I want to give a huge shout-out to a new contributor, @aarshkshah1992, for making all these changes happen.

1 Like