Remove libp2p config option passthrough

No code uses this libp2p-specific hardwiring provision.
pull/456/head
Eugene Kim 6 years ago
parent 292fc38d49
commit f24509594e
  1. 5
      p2p/host/hostv2/hostv2.go
  2. 5
      p2p/p2pimpl/p2pimpl.go

@ -18,7 +18,6 @@ import (
peerstore "github.com/libp2p/go-libp2p-peerstore" peerstore "github.com/libp2p/go-libp2p-peerstore"
protocol "github.com/libp2p/go-libp2p-protocol" protocol "github.com/libp2p/go-libp2p-protocol"
pubsub "github.com/libp2p/go-libp2p-pubsub" pubsub "github.com/libp2p/go-libp2p-pubsub"
p2p_config "github.com/libp2p/go-libp2p/config"
ma "github.com/multiformats/go-multiaddr" ma "github.com/multiformats/go-multiaddr"
) )
@ -150,7 +149,7 @@ func (host *HostV2) Peerstore() peerstore.Peerstore {
} }
// New creates a host for p2p communication // New creates a host for p2p communication
func New(self *p2p.Peer, priKey p2p_crypto.PrivKey, opts ...p2p_config.Option) *HostV2 { func New(self *p2p.Peer, priKey p2p_crypto.PrivKey) *HostV2 {
listenAddr, err := ma.NewMultiaddr(fmt.Sprintf("/ip4/0.0.0.0/tcp/%s", self.Port)) listenAddr, err := ma.NewMultiaddr(fmt.Sprintf("/ip4/0.0.0.0/tcp/%s", self.Port))
if err != nil { if err != nil {
log.Error("New MA Error", "IP", self.IP, "Port", self.Port) log.Error("New MA Error", "IP", self.IP, "Port", self.Port)
@ -159,7 +158,7 @@ func New(self *p2p.Peer, priKey p2p_crypto.PrivKey, opts ...p2p_config.Option) *
// TODO – use WithCancel for orderly host teardown (which we don't have yet) // TODO – use WithCancel for orderly host teardown (which we don't have yet)
ctx := context.Background() ctx := context.Background()
p2pHost, err := libp2p.New(ctx, p2pHost, err := libp2p.New(ctx,
append(opts, libp2p.ListenAddrs(listenAddr), libp2p.Identity(priKey))..., libp2p.ListenAddrs(listenAddr), libp2p.Identity(priKey),
) )
catchError(err) catchError(err)
pubsub, err := pubsub.NewGossipSub(ctx, p2pHost) pubsub, err := pubsub.NewGossipSub(ctx, p2pHost)

@ -8,14 +8,13 @@ import (
"github.com/harmony-one/harmony/internal/utils" "github.com/harmony-one/harmony/internal/utils"
p2p_crypto "github.com/libp2p/go-libp2p-crypto" p2p_crypto "github.com/libp2p/go-libp2p-crypto"
p2p_config "github.com/libp2p/go-libp2p/config"
) )
// NewHost starts the host for p2p // NewHost starts the host for p2p
// for hostv2, it generates multiaddress, keypair and add PeerID to peer, add priKey to host // for hostv2, it generates multiaddress, keypair and add PeerID to peer, add priKey to host
// TODO (leo) The peerstore has to be persisted on disk. // TODO (leo) The peerstore has to be persisted on disk.
func NewHost(self *p2p.Peer, key p2p_crypto.PrivKey, opts ...p2p_config.Option) (p2p.Host, error) { func NewHost(self *p2p.Peer, key p2p_crypto.PrivKey) (p2p.Host, error) {
h := hostv2.New(self, key, opts...) h := hostv2.New(self, key)
utils.GetLogInstance().Info("NewHost", "self", net.JoinHostPort(self.IP, self.Port), "PeerID", self.PeerID) utils.GetLogInstance().Info("NewHost", "self", net.JoinHostPort(self.IP, self.Port), "PeerID", self.PeerID)

Loading…
Cancel
Save