github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/network/proxy/network.go (about) 1 package proxy 2 3 import ( 4 "github.com/onflow/flow-go/model/flow" 5 "github.com/onflow/flow-go/network" 6 "github.com/onflow/flow-go/network/channels" 7 ) 8 9 type ProxyNetwork struct { 10 network.EngineRegistry 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.EngineRegistry, 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.EngineRegistry.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 }