github.com/ethersphere/bee/v2@v2.2.0/pkg/p2p/libp2p/export_test.go (about)

     1  // Copyright 2020 The Swarm Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package libp2p
     6  
     7  import (
     8  	"context"
     9  
    10  	handshake "github.com/ethersphere/bee/v2/pkg/p2p/libp2p/internal/handshake"
    11  	libp2pm "github.com/libp2p/go-libp2p"
    12  	"github.com/libp2p/go-libp2p/core/host"
    13  	"github.com/libp2p/go-libp2p/core/network"
    14  	libp2ppeer "github.com/libp2p/go-libp2p/core/peer"
    15  )
    16  
    17  func (s *Service) HandshakeService() *handshake.Service {
    18  	return s.handshakeService
    19  }
    20  
    21  func (s *Service) NewStreamForPeerID(peerID libp2ppeer.ID, protocolName, protocolVersion, streamName string) (network.Stream, error) {
    22  	return s.newStreamForPeerID(context.Background(), peerID, protocolName, protocolVersion, streamName)
    23  }
    24  
    25  func (s *Service) WrapStream(ns network.Stream) *stream {
    26  	return newStream(ns, s.metrics)
    27  }
    28  
    29  func (s *Service) Host() host.Host {
    30  	return s.host
    31  }
    32  
    33  type StaticAddressResolver = staticAddressResolver
    34  
    35  var (
    36  	NewStaticAddressResolver = newStaticAddressResolver
    37  	UserAgent                = userAgent
    38  )
    39  
    40  func WithHostFactory(factory func(...libp2pm.Option) (host.Host, error)) Options {
    41  	return Options{
    42  		hostFactory: factory,
    43  	}
    44  }