Closed dennis-tra closed 9 months ago
The Dual DHT is essentially a wrapper around two IpfsDHT
, one local and one global.
type DHT struct {
WAN *dht.IpfsDHT
LAN *dht.IpfsDHT
}
The dual
DHT
implements the following interfaces from the github.com/libp2p/go-libp2p/core/routing
package.
ContentRouting
Routing
PeerRouting
PubKeyFetcher
ValueStore
The Dual DHT takes dht.Option
for (1) the global, (2) the local and (3) both DHTs. We want to adapt the following the match the Config
from v2
.
// WanDHTOption applies the given DHT options to the WAN DHT.
func WanDHTOption(opts ...dht.Option) Option {
return func(c *config) error {
c.wan = append(c.wan, opts...)
return nil
}
}
// LanDHTOption applies the given DHT options to the LAN DHT.
func LanDHTOption(opts ...dht.Option) Option {
return func(c *config) error {
c.lan = append(c.lan, opts...)
return nil
}
}
// DHTOption applies the given DHT options to both the WAN and the LAN DHTs.
func DHTOption(opts ...dht.Option) Option {
return func(c *config) error {
c.lan = append(c.lan, opts...)
c.wan = append(c.wan, opts...)
return nil
}
}
The routing methods (e.g FindPeer
, FindProvidersAsync
, Provide
etc.) essentially define the Dual DHT behavior wrt. the two active DHTs, so most of the code can be copied over to v2
.
As per 2023-09-29, we agreed not to implement the Dual DHT. The Dual DHT has no reason to exist as it can now be implemented easily with https://github.com/libp2p/go-libp2p-routing-helpers.
Research how this relates to
routing.Routing