github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/network/p2p/stream.go (about)

     1  package p2p
     2  
     3  import (
     4  	"context"
     5  
     6  	"github.com/libp2p/go-libp2p/core/network"
     7  	"github.com/libp2p/go-libp2p/core/peer"
     8  	"github.com/libp2p/go-libp2p/core/protocol"
     9  )
    10  
    11  // StreamFactory is a wrapper around libp2p host.Host to provide abstraction and encapsulation for unicast stream manager so that
    12  // it can create libp2p streams with finer granularity.
    13  type StreamFactory interface {
    14  	SetStreamHandler(protocol.ID, network.StreamHandler)
    15  	// NewStream creates a new stream on the libp2p host.
    16  	// Expected errors during normal operations:
    17  	//   - ErrProtocolNotSupported this indicates remote node is running on a different spork.
    18  	NewStream(context.Context, peer.ID, protocol.ID) (network.Stream, error)
    19  }