Change DHT implementation to dual DHT

This commit is contained in:
ChronosX88 2020-10-22 02:04:31 +04:00
parent 1f059b7fcd
commit d47925db4b
Signed by: ChronosXYZ
GPG Key ID: 085A69A82C8C511A

View File

@ -5,6 +5,7 @@ import (
"crypto/rand" "crypto/rand"
"flag" "flag"
"fmt" "fmt"
"github.com/libp2p/go-libp2p-kad-dht/dual"
"sync" "sync"
"time" "time"
@ -18,7 +19,6 @@ import (
"github.com/libp2p/go-libp2p-core/host" "github.com/libp2p/go-libp2p-core/host"
peer "github.com/libp2p/go-libp2p-core/peer" peer "github.com/libp2p/go-libp2p-core/peer"
discovery "github.com/libp2p/go-libp2p-discovery" discovery "github.com/libp2p/go-libp2p-discovery"
dht "github.com/libp2p/go-libp2p-kad-dht"
peerstore "github.com/libp2p/go-libp2p-peerstore" peerstore "github.com/libp2p/go-libp2p-peerstore"
"github.com/multiformats/go-multiaddr" "github.com/multiformats/go-multiaddr"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
@ -98,9 +98,9 @@ func (n *Node) setupLibp2pHost(ctx context.Context, privateKey crypto.PrivKey) {
} }
n.Host = host n.Host = host
logrus.Info(fmt.Sprintf("[*] Your Multiaddress Is: /ip4/%s/tcp/%v/p2p/%s\n", n.Config.ListenAddr, n.Config.ListenPort, host.ID().Pretty())) logrus.Info(fmt.Sprintf("[*] Your Multiaddress Is: /ip4/%s/tcp/%v/p2p/%s", n.Config.ListenAddr, n.Config.ListenPort, host.ID().Pretty()))
kademliaDHT, err := dht.New(context.Background(), n.Host) kademliaDHT, err := dual.New(context.Background(), n.Host)
if err != nil { if err != nil {
logrus.Fatal("Failed to create new DHT instance: ", err) logrus.Fatal("Failed to create new DHT instance: ", err)
} }