github.com/koko1123/flow-go-1@v0.29.6/module/dkg/tunnel.go (about) 1 package dkg 2 3 import ( 4 "github.com/koko1123/flow-go-1/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. 10 type BrokerTunnel struct { 11 MsgChIn chan messages.PrivDKGMessageIn // from network engine to broker 12 MsgChOut chan messages.PrivDKGMessageOut // from broker to network engine 13 } 14 15 // NewBrokerTunnel instantiates a new BrokerTunnel 16 func NewBrokerTunnel() *BrokerTunnel { 17 return &BrokerTunnel{ 18 MsgChIn: make(chan messages.PrivDKGMessageIn), 19 MsgChOut: make(chan messages.PrivDKGMessageOut), 20 } 21 } 22 23 // SendIn pushes incoming messages in the MsgChIn channel to be received by the 24 // Broker. 25 func (t *BrokerTunnel) SendIn(msg messages.PrivDKGMessageIn) { 26 t.MsgChIn <- msg 27 } 28 29 // SendOut pushes outcoing messages in the MsgChOut channel to be received and 30 // forwarded by the network engine. 31 func (t *BrokerTunnel) SendOut(msg messages.PrivDKGMessageOut) { 32 t.MsgChOut <- msg 33 }