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 withBootstrapWithConfig
:- 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 callRefresh()
. -
BootstrapRandom
has been removed in favor ofRefresh()
. -
BootstrapOnce
has been removed in favor ofRefresh()
. - The global
DefaultBootstrapConfig
has been removed along with theBootstrapConfig
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, callRefresh()
. - 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.
- DisableAutoRefresh - Never automatically refresh the routing tables. If you pass this, you’ll need to manually invoke
Thanks: I want to give a huge shout-out to a new contributor, @aarshkshah1992, for making all these changes happen.