How to enable/disable DHT Random Walks?

Couldn’t find any mention on how to set this up in the examples, https://godoc.org/github.com/libp2p/go-libp2p and https://godoc.org/github.com/libp2p/go-libp2p-kad-dht

Relevant thread https://github.com/libp2p/go-libp2p/issues/222

@daviddias:

I think Go-libp2p-kad-dht 0.3.0 released with breaking changes is exactly what you are looking for.

“Dht Randoms Walks” / “Dht Refresh” / “Look for random peer IDs in the network” is enabled by default(One aim of this release & that great writeup by @stebalien is to clear the confusing terminology).

However, you can disable it by passing in the DisableAutoRefresh option to the Dht. Then, you will have to “manually” call Dht.Refresh to perform random walks.

Please do let me know if you have any questions.

1 Like

It is indeed. Thank you @stebalien for releasing it for me :heart:

For future selves and others looking for the answer, you can find a snippet om how it is done at:
https://github.com/ipfs/testground/blob/961986448609433db0bd7bf8e074d4d06b290a4d/plans/dht/utils/create-dht-node.go#L33-L45