github.com/koko1123/flow-go-1@v0.29.6/network/p2p/unicast/plain.go (about) 1 package unicast 2 3 import ( 4 libp2pnet "github.com/libp2p/go-libp2p/core/network" 5 "github.com/libp2p/go-libp2p/core/protocol" 6 ) 7 8 // PlainStream is a stream factory that reflects the same input stream without any modification. 9 type PlainStream struct { 10 handler libp2pnet.StreamHandler 11 protocolId protocol.ID 12 } 13 14 // UpgradeRawStream implements protocol interface and returns the input stream without any modification. 15 func (p PlainStream) UpgradeRawStream(s libp2pnet.Stream) (libp2pnet.Stream, error) { 16 return s, nil 17 } 18 19 func (p PlainStream) Handler(s libp2pnet.Stream) { 20 p.handler(s) 21 } 22 23 func (p PlainStream) ProtocolId() protocol.ID { 24 return p.protocolId 25 }