github.com/annchain/OG@v0.0.9/plugin/og/handler.go (about) 1 package og 2 3 import ( 4 "github.com/annchain/OG/message" 5 "github.com/annchain/OG/ogcore" 6 "github.com/annchain/OG/ogcore/communication" 7 "github.com/sirupsen/logrus" 8 ) 9 10 type OgGeneralMessageHandler struct { 11 OgPartner *ogcore.OgPartner 12 OgMessageAdapter OgMessageAdapter 13 } 14 15 func (a OgGeneralMessageHandler) Handle(msgEvent *message.GeneralMessageEvent) { 16 annsensusMessage, err := a.OgMessageAdapter.AdaptGeneralMessage(msgEvent.Message) 17 if err != nil { 18 logrus.WithError(err).Warn("failed to adapt og message to general") 19 return 20 } 21 ogPeer, err := a.OgMessageAdapter.AdaptGeneralPeer(msgEvent.Sender) 22 if err != nil { 23 logrus.WithError(err).Warn("failed to adapt general peer to og") 24 return 25 } 26 ogMsgEvent := &communication.OgMessageEvent{ 27 Message: annsensusMessage, 28 Peer: ogPeer, 29 } 30 a.OgPartner.PeerIncoming.GetPipeIn() <- ogMsgEvent 31 //<-ffchan.NewTimeoutSenderShort(a.OgPartner.PeerIncoming.GetPipeIn(), ogMsgEvent, "og handler").C 32 33 }