handleMessage is called by ProcessStream to dispatch messages.
(msg *pb.ChaincodeMessage)
| 162 | |
| 163 | // handleMessage is called by ProcessStream to dispatch messages. |
| 164 | func (h *Handler) handleMessage(msg *pb.ChaincodeMessage) error { |
| 165 | h.stateLock.RLock() |
| 166 | state := h.state |
| 167 | h.stateLock.RUnlock() |
| 168 | |
| 169 | chaincodeLogger.Debugf("[%s] Fabric side handling ChaincodeMessage of type: %s in state %s", shorttxid(msg.Txid), msg.Type, state) |
| 170 | |
| 171 | if msg.Type == pb.ChaincodeMessage_KEEPALIVE { |
| 172 | return nil |
| 173 | } |
| 174 | |
| 175 | switch state { |
| 176 | case Created: |
| 177 | return h.handleMessageCreatedState(msg) |
| 178 | case Ready: |
| 179 | return h.handleMessageReadyState(msg) |
| 180 | default: |
| 181 | return errors.Errorf("handle message: invalid state %s for transaction %s", state, msg.Txid) |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | func (h *Handler) handleMessageCreatedState(msg *pb.ChaincodeMessage) error { |
| 186 | switch msg.Type { |
no test coverage detected