github.com/koko1123/flow-go-1@v0.29.6/network/proxy/network.go (about) 1 package proxy 2 3 import ( 4 "github.com/koko1123/flow-go-1/model/flow" 5 "github.com/koko1123/flow-go-1/network" 6 "github.com/koko1123/flow-go-1/network/channels" 7 ) 8 9 type ProxyNetwork struct { 10 network.Network 11 targetNodeID flow.Identifier 12 } 13 14 // NewProxyNetwork creates a new proxy network. All messages sent on this network are 15 // sent only to the node identified by the given target ID. 16 func NewProxyNetwork(net network.Network, targetNodeID flow.Identifier) *ProxyNetwork { 17 return &ProxyNetwork{ 18 net, 19 targetNodeID, 20 } 21 } 22 23 // Register registers an engine with the proxy network. 24 func (n *ProxyNetwork) Register(channel channels.Channel, engine network.Engine) (network.Conduit, error) { 25 con, err := n.Network.Register(channel, engine) 26 27 if err != nil { 28 return nil, err 29 } 30 31 proxyCon := ProxyConduit{ 32 con, 33 n.targetNodeID, 34 } 35 36 return &proxyCon, nil 37 }