github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/module/dkg/tunnel.go (about) 1 package dkg 2 3 import ( 4 "github.com/onflow/flow-go/model/messages" 5 ) 6 7 // BrokerTunnel allows the DKG MessagingEngine to relay messages to and from a 8 // loosely-coupled Broker and Controller. The same BrokerTunnel is intended 9 // to be reused across epochs (multiple DKG instances). The BrokerTunnel does 10 // not internally queue messages, so sends through the tunnel are blocking. 11 type BrokerTunnel struct { 12 MsgChIn chan messages.PrivDKGMessageIn // from network engine to broker 13 MsgChOut chan messages.PrivDKGMessageOut // from broker to network engine 14 } 15 16 // NewBrokerTunnel instantiates a new BrokerTunnel. 17 func NewBrokerTunnel() *BrokerTunnel { 18 return &BrokerTunnel{ 19 MsgChIn: make(chan messages.PrivDKGMessageIn), 20 MsgChOut: make(chan messages.PrivDKGMessageOut), 21 } 22 } 23 24 // SendIn pushes incoming messages in the MsgChIn channel to be received by the Broker. 25 // This is a blocking call (messages are not queued within the tunnel) 26 func (t *BrokerTunnel) SendIn(msg messages.PrivDKGMessageIn) { 27 t.MsgChIn <- msg 28 } 29 30 // SendOut pushes outbound messages in the MsgChOut channel to be received and 31 // forwarded by the network engine. 32 // This is a blocking call (messages are not queued within the tunnel) 33 func (t *BrokerTunnel) SendOut(msg messages.PrivDKGMessageOut) { 34 t.MsgChOut <- msg 35 }