diff --git a/node/builder.go b/node/builder.go index 178f973e5..dd0af277d 100644 --- a/node/builder.go +++ b/node/builder.go @@ -58,7 +58,6 @@ type special struct{ id int } //nolint:golint var ( DefaultTransportsKey = special{0} // Libp2p option - PNetKey = special{1} // Option + multiret DiscoveryHandlerKey = special{2} // Private type AddrsFactoryKey = special{3} // Libp2p option SmuxTransportKey = special{4} // Libp2p option @@ -142,7 +141,6 @@ func libp2p() Option { Override(new(peerstore.Peerstore), pstoremem.NewPeerstore), Override(DefaultTransportsKey, lp2p.DefaultTransports), - Override(PNetKey, lp2p.PNet), Override(new(lp2p.RawHost), lp2p.Host), Override(new(host.Host), lp2p.RoutedHost), diff --git a/node/modules/lp2p/host.go b/node/modules/lp2p/host.go index ccb579763..6809d4a5c 100644 --- a/node/modules/lp2p/host.go +++ b/node/modules/lp2p/host.go @@ -79,6 +79,7 @@ func DHTRouting(client bool) interface{} { dhtopts.Client(client), dhtopts.Datastore(dstore), dhtopts.Validator(validator), + dhtopts.Protocols("/lotus/kad/1.0.0"), ) if err != nil { diff --git a/node/modules/lp2p/pnet.go b/node/modules/lp2p/pnet.go deleted file mode 100644 index f182be125..000000000 --- a/node/modules/lp2p/pnet.go +++ /dev/null @@ -1,63 +0,0 @@ -package lp2p - -import ( - "fmt" - "strings" - - "github.com/libp2p/go-libp2p" - pnet "github.com/libp2p/go-libp2p-pnet" -) - -var LotusKey = "/key/swarm/psk/1.0.0/\n/base16/\n20c72388e6299c7bbc1b501fdcc8abe4f89f798e9b93b2d2bc02e3c29b6a088e" - -type PNetFingerprint []byte - -func PNet() (opts Libp2pOpts, fp PNetFingerprint, err error) { - protec, err := pnet.NewProtector(strings.NewReader(LotusKey)) - if err != nil { - return opts, nil, fmt.Errorf("failed to configure private network: %s", err) - } - fp = protec.Fingerprint() - - opts.Opts = append(opts.Opts, libp2p.PrivateNetwork(protec)) - return opts, fp, nil -} - -/* -func PNetChecker(repo repo.Repo, ph host.Host, lc fx.Lifecycle) error { - // TODO: better check? - swarmkey, err := repo.SwarmKey() - if err != nil || swarmkey == nil { - return err - } - - done := make(chan struct{}) - lc.Append(fx.Hook{ - OnStart: func(_ context.Context) error { - go func() { - t := time.NewTicker(30 * time.Second) - defer t.Stop() - - <-t.C // swallow one tick - for { - select { - case <-t.C: - if len(ph.Network().Peers()) == 0 { - log.Warn("We are in private network and have no peers.") - log.Warn("This might be configuration mistake.") - } - case <-done: - return - } - } - }() - return nil - }, - OnStop: func(_ context.Context) error { - close(done) - return nil - }, - }) - return nil -} -*/