Skip to content

Commit 3261ce1

Browse files
committed
[FAB-14770] sendChannel -> handleResponse
... and use "responseChan" instead of "c" to refer to the channel that's used to carry transaction response messages to callers of sendReceive Change-Id: I38f1febe96bcf4f057829b5c7850d25a5da3ccd6 Signed-off-by: Matthew Sykes <sykesmat@us.ibm.com>
1 parent 2311b5a commit 3261ce1

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

core/chaincode/shim/handler.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,12 @@ func (h *Handler) createChannel(channelID, txid string) (<-chan pb.ChaincodeMess
9393
return nil, errors.Errorf("[%s] channel exists", shorttxid(txCtxID))
9494
}
9595

96-
c := make(chan pb.ChaincodeMessage)
97-
h.responseChannels[txCtxID] = c
98-
return c, nil
96+
responseChan := make(chan pb.ChaincodeMessage)
97+
h.responseChannels[txCtxID] = responseChan
98+
return responseChan, nil
9999
}
100100

101-
func (h *Handler) sendChannel(msg *pb.ChaincodeMessage) error {
101+
func (h *Handler) handleResponse(msg *pb.ChaincodeMessage) error {
102102
h.responseChannelsMutex.Lock()
103103
defer h.responseChannelsMutex.Unlock()
104104

@@ -109,7 +109,7 @@ func (h *Handler) sendChannel(msg *pb.ChaincodeMessage) error {
109109
txCtxID := h.getTxCtxId(msg.ChannelId, msg.Txid)
110110
responseCh := h.responseChannels[txCtxID]
111111
if responseCh == nil {
112-
return errors.Errorf("[%s] sendChannel does not exist", shorttxid(msg.Txid))
112+
return errors.Errorf("[%s] responseChannel does not exist", shorttxid(msg.Txid))
113113
}
114114

115115
chaincodeLogger.Debugf("[%s] before send", shorttxid(msg.Txid))
@@ -120,7 +120,7 @@ func (h *Handler) sendChannel(msg *pb.ChaincodeMessage) error {
120120
}
121121

122122
//sends a message and selects
123-
func (h *Handler) sendReceive(msg *pb.ChaincodeMessage, c <-chan pb.ChaincodeMessage) (pb.ChaincodeMessage, error) {
123+
func (h *Handler) sendReceive(msg *pb.ChaincodeMessage, responseChan <-chan pb.ChaincodeMessage) (pb.ChaincodeMessage, error) {
124124
errc := make(chan error, 1)
125125
h.serialSendAsync(msg, errc)
126126

@@ -136,7 +136,7 @@ func (h *Handler) sendReceive(msg *pb.ChaincodeMessage, c <-chan pb.ChaincodeMes
136136
if err != nil {
137137
return pb.ChaincodeMessage{}, err
138138
}
139-
case outmsg, val := <-c:
139+
case outmsg, val := <-responseChan:
140140
if !val {
141141
return pb.ChaincodeMessage{}, errors.New("unexpected failure on receive")
142142
}
@@ -749,7 +749,7 @@ func (h *Handler) handleInvokeChaincode(chaincodeName string, args [][]byte, cha
749749
func (h *Handler) handleReady(msg *pb.ChaincodeMessage, errc chan error) error {
750750
switch msg.Type {
751751
case pb.ChaincodeMessage_RESPONSE, pb.ChaincodeMessage_ERROR:
752-
if err := h.sendChannel(msg); err != nil {
752+
if err := h.handleResponse(msg); err != nil {
753753
chaincodeLogger.Errorf("[%s] error sending %s (state:%s): %s", shorttxid(msg.Txid), msg.Type, h.state, err)
754754
return err
755755
}

0 commit comments

Comments
 (0)