MCPcopy Create free account
hub / github.com/DNAProject/DNA / hookChan

Method hookChan

p2pserver/message/utils/msg_router.go:101–125  ·  view source on GitHub ↗

hookChan loops to handle the message from the network

(channel chan *types.MsgPayload,
	stopCh chan bool)

Source from the content-addressed store, hash-verified

99
100// hookChan loops to handle the message from the network
101func (this *MessageRouter) hookChan(channel chan *types.MsgPayload,
102 stopCh chan bool) {
103 for {
104 select {
105 case data, ok := <-channel:
106 if ok {
107 msgType := data.Payload.CmdType()
108
109 handler, ok := this.msgHandlers[msgType]
110 if ok {
111 if msgType == msgCommon.TX_TYPE {
112 handler(data, this.p2p, this.pid)
113 } else {
114 go handler(data, this.p2p, this.pid)
115 }
116 } else {
117 log.Warn("unknown message handler for the msg: ",
118 msgType)
119 }
120 }
121 case <-stopCh:
122 return
123 }
124 }
125}
126
127// Stop stops the message router's loop
128func (this *MessageRouter) Stop() {

Callers 1

StartMethod · 0.95

Calls 3

WarnFunction · 0.92
CmdTypeMethod · 0.65
handlerFuncType · 0.50

Tested by

no test coverage detected