github.com/koko1123/flow-go-1@v0.29.6/network/converter/network.go (about) 1 package converter 2 3 import ( 4 "github.com/koko1123/flow-go-1/network" 5 "github.com/koko1123/flow-go-1/network/channels" 6 ) 7 8 type Network struct { 9 network.Network 10 from channels.Channel 11 to channels.Channel 12 } 13 14 func NewNetwork(net network.Network, from channels.Channel, to channels.Channel) *Network { 15 return &Network{net, from, to} 16 } 17 18 func (n *Network) convert(channel channels.Channel) channels.Channel { 19 if channel == n.from { 20 return n.to 21 } 22 return channel 23 } 24 25 func (n *Network) Register(channel channels.Channel, engine network.MessageProcessor) (network.Conduit, error) { 26 return n.Network.Register(n.convert(channel), engine) 27 }