Skip to content

Commit 05c8272

Browse files
committed
[FAB-9811] Space should follow comment delimiter
Change-Id: I42718294ffc96375c6f3077e5214695fd65241f4 Signed-off-by: Matthew Sykes <sykesmat@us.ibm.com>
1 parent de11826 commit 05c8272

File tree

1 file changed

+51
-51
lines changed

1 file changed

+51
-51
lines changed

core/chaincode/handler.go

+51-51
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ import (
3030
type state string
3131

3232
const (
33-
created state = "created" //start state
34-
established state = "established" //in: CREATED, rcv: REGISTER, send: REGISTERED
35-
ready state = "ready" //in:ESTABLISHED, rcv:COMPLETED
33+
created state = "created" // start state
34+
established state = "established" // in:CREATED, rcv:REGISTER, send: REGISTERED
35+
ready state = "ready" // in:ESTABLISHED, rcv:COMPLETED
3636

3737
)
3838

@@ -58,7 +58,7 @@ type handlerSupport interface {
5858

5959
// Handler responsible for management of Peer's side of chaincode stream
6060
type Handler struct {
61-
//peer to shim grpc serializer. User only in serialSend
61+
// peer to shim grpc serializer. User only in serialSend
6262
serialLock sync.Mutex
6363
ChatStream ccintf.ChaincodeStream
6464
state state
@@ -70,7 +70,7 @@ type Handler struct {
7070

7171
sccp sysccprovider.SystemChaincodeProvider
7272

73-
//chan to pass error in sync and nonsync mode
73+
// chan to pass error in sync and nonsync mode
7474
errChan chan error
7575

7676
// Map of tx txid to either invoke tx. Each tx will be
@@ -165,13 +165,13 @@ func shorttxid(txid string) string {
165165
return txid[0:8]
166166
}
167167

168-
//gets chaincode instance from the canonical name of the chaincode.
169-
//Called exactly once per chaincode when registering chaincode.
170-
//This is needed for the "one-instance-per-chain" model when
171-
//starting up the chaincode for each chain. It will still
172-
//work for the "one-instance-for-all-chains" as the version
173-
//and suffix will just be absent (also note that LSCC reserves
174-
//"/:[]${}" as special chars mainly for such namespace uses)
168+
// gets chaincode instance from the canonical name of the chaincode.
169+
// Called exactly once per chaincode when registering chaincode.
170+
// This is needed for the "one-instance-per-chain" model when
171+
// starting up the chaincode for each chain. It will still
172+
// work for the "one-instance-for-all-chains" as the version
173+
// and suffix will just be absent (also note that LSCC reserves
174+
// "/:[]${}" as special chars mainly for such namespace uses)
175175
func (h *Handler) decomposeRegisteredName(cid *pb.ChaincodeID) {
176176
h.ccInstance = getChaincodeInstance(cid.Name)
177177
}
@@ -180,7 +180,7 @@ func getChaincodeInstance(ccName string) *sysccprovider.ChaincodeInstance {
180180
b := []byte(ccName)
181181
ci := &sysccprovider.ChaincodeInstance{}
182182

183-
//compute suffix (ie, chain name)
183+
// compute suffix (ie, chain name)
184184
i := bytes.IndexByte(b, '/')
185185
if i >= 0 {
186186
if i < len(b)-1 {
@@ -189,7 +189,7 @@ func getChaincodeInstance(ccName string) *sysccprovider.ChaincodeInstance {
189189
b = b[:i]
190190
}
191191

192-
//compute version
192+
// compute version
193193
i = bytes.IndexByte(b, ':')
194194
if i >= 0 {
195195
if i < len(b)-1 {
@@ -207,7 +207,7 @@ func (h *Handler) getCCRootName() string {
207207
return h.ccInstance.ChaincodeName
208208
}
209209

210-
//serialSend serializes msgs so gRPC will be happy
210+
// serialSend serializes msgs so gRPC will be happy
211211
func (h *Handler) serialSend(msg *pb.ChaincodeMessage) error {
212212
h.serialLock.Lock()
213213
defer h.serialLock.Unlock()
@@ -220,11 +220,11 @@ func (h *Handler) serialSend(msg *pb.ChaincodeMessage) error {
220220
return err
221221
}
222222

223-
//serialSendAsync serves the same purpose as serialSend (serialize msgs so gRPC will
224-
//be happy). In addition, it is also asynchronous so send-remoterecv--localrecv loop
225-
//can be nonblocking. Only errors need to be handled and these are handled by
226-
//communication on supplied error channel. A typical use will be a non-blocking or
227-
//nil channel
223+
// serialSendAsync serves the same purpose as serialSend (serialize msgs so gRPC will
224+
// be happy). In addition, it is also asynchronous so send-remoterecv--localrecv loop
225+
// can be nonblocking. Only errors need to be handled and these are handled by
226+
// communication on supplied error channel. A typical use will be a non-blocking or
227+
// nil channel
228228
func (h *Handler) serialSendAsync(msg *pb.ChaincodeMessage, sendErr bool) {
229229
go func() {
230230
if err := h.serialSend(msg); err != nil {
@@ -235,9 +235,9 @@ func (h *Handler) serialSendAsync(msg *pb.ChaincodeMessage, sendErr bool) {
235235
}()
236236
}
237237

238-
//transaction context id should be composed of chainID and txid. While
239-
//needed for CC-2-CC, it also allows users to concurrently send proposals
240-
//with the same TXID to the SAME CC on multiple channels
238+
// transaction context id should be composed of chainID and txid. While
239+
// needed for CC-2-CC, it also allows users to concurrently send proposals
240+
// with the same TXID to the SAME CC on multiple channels
241241
func (h *Handler) getTxCtxId(chainID string, txid string) string {
242242
return chainID + txid
243243
}
@@ -300,7 +300,7 @@ func (h *Handler) waitForKeepaliveTimer() <-chan time.Time {
300300
func (h *Handler) processStream() error {
301301
defer h.deregister()
302302

303-
//holds return values from gRPC Recv below
303+
// holds return values from gRPC Recv below
304304
type recvMsg struct {
305305
msg *pb.ChaincodeMessage
306306
err error
@@ -311,11 +311,11 @@ func (h *Handler) processStream() error {
311311
var in *pb.ChaincodeMessage
312312
var err error
313313

314-
//recv is used to spin Recv routine after previous received msg
315-
//has been processed
314+
// recv is used to spin Recv routine after previous received msg
315+
// has been processed
316316
recv := true
317317

318-
//catch send errors and bail now that sends aren't synchronous
318+
// catch send errors and bail now that sends aren't synchronous
319319
for {
320320
in = nil
321321
err = nil
@@ -365,8 +365,8 @@ func (h *Handler) processStream() error {
365365
continue
366366
}
367367

368-
//if no error message from serialSend, KEEPALIVE happy, and don't care about error
369-
//(maybe it'll work later)
368+
// if no error message from serialSend, KEEPALIVE happy, and don't care about error
369+
// (maybe it'll work later)
370370
h.serialSendAsync(&pb.ChaincodeMessage{Type: pb.ChaincodeMessage_KEEPALIVE}, false)
371371
continue
372372
}
@@ -396,12 +396,12 @@ func (h *Handler) deleteTXIDEntry(channelID, txid string) {
396396
h.activeTransactions.Remove(channelID, txid)
397397
}
398398

399-
//sendReady sends READY to chaincode serially (just like REGISTER)
399+
// sendReady sends READY to chaincode serially (just like REGISTER)
400400
func (h *Handler) sendReady() error {
401401
chaincodeLogger.Debugf("sending READY for chaincode %+v", h.ChaincodeID)
402402
ccMsg := &pb.ChaincodeMessage{Type: pb.ChaincodeMessage_READY}
403403

404-
//if error in sending tear down the h
404+
// if error in sending tear down the h
405405
if err := h.serialSend(ccMsg); err != nil {
406406
chaincodeLogger.Errorf("error sending READY (%s) for chaincode %+v", err, h.ChaincodeID)
407407
return err
@@ -415,11 +415,11 @@ func (h *Handler) sendReady() error {
415415
return nil
416416
}
417417

418-
//notifyDuringStartup will send ready on registration
418+
// notifyDuringStartup will send ready on registration
419419
func (h *Handler) notifyDuringStartup(val bool) {
420420
if val {
421-
//if send failed, notify failure which will initiate
422-
//tearing down
421+
// if send failed, notify failure which will initiate
422+
// tearing down
423423
if err := h.sendReady(); err != nil {
424424
chaincodeLogger.Debugf("sendReady failed: %s", err)
425425
}
@@ -444,8 +444,8 @@ func (h *Handler) handleRegister(msg *pb.ChaincodeMessage) {
444444
return
445445
}
446446

447-
//get the component parts so we can use the root chaincode
448-
//name in keys
447+
// get the component parts so we can use the root chaincode
448+
// name in keys
449449
h.decomposeRegisteredName(h.ChaincodeID)
450450

451451
chaincodeLogger.Debugf("Got %s for chaincodeID = %s, sending back %s", pb.ChaincodeMessage_REGISTER, chaincodeID, pb.ChaincodeMessage_REGISTERED)
@@ -459,7 +459,7 @@ func (h *Handler) handleRegister(msg *pb.ChaincodeMessage) {
459459

460460
chaincodeLogger.Debugf("Changed state to established for %+v", h.ChaincodeID)
461461

462-
//for dev mode this will also move to ready automatically
462+
// for dev mode this will also move to ready automatically
463463
h.notifyDuringStartup(true)
464464
}
465465

@@ -487,7 +487,7 @@ func (h *Handler) isValidTxSim(channelID string, txid string, fmtStr string, arg
487487
return txContext, nil
488488
}
489489

490-
//register Txid to prevent overlapping handle messages from chaincode
490+
// register Txid to prevent overlapping handle messages from chaincode
491491
func (h *Handler) registerTxid(msg *pb.ChaincodeMessage) bool {
492492
// Check if this is the unique state request from this chaincode txid
493493
if uniqueReq := h.createTXIDEntry(msg.ChannelId, msg.Txid); !uniqueReq {
@@ -498,7 +498,7 @@ func (h *Handler) registerTxid(msg *pb.ChaincodeMessage) bool {
498498
return true
499499
}
500500

501-
//deregister current txid on completion
501+
// deregister current txid on completion
502502
func (h *Handler) deRegisterTxid(msg, serialSendMsg *pb.ChaincodeMessage, serial bool) {
503503
h.deleteTXIDEntry(msg.ChannelId, msg.Txid)
504504
chaincodeLogger.Debugf("[%s]send %s(serial-%t)", shorttxid(serialSendMsg.Txid), serialSendMsg.Type, serial)
@@ -551,7 +551,7 @@ func (h *Handler) handleGetState(msg *pb.ChaincodeMessage) {
551551
shorttxid(msg.Txid), err, pb.ChaincodeMessage_ERROR)
552552
serialSendMsg = &pb.ChaincodeMessage{Type: pb.ChaincodeMessage_ERROR, Payload: payload, Txid: msg.Txid, ChannelId: msg.ChannelId}
553553
} else if res == nil {
554-
//The state object being requested does not exist
554+
// The state object being requested does not exist
555555
chaincodeLogger.Debugf("[%s]No state associated with key: %s. Sending %s with an empty payload",
556556
shorttxid(msg.Txid), key, pb.ChaincodeMessage_RESPONSE)
557557
serialSendMsg = &pb.ChaincodeMessage{Type: pb.ChaincodeMessage_RESPONSE, Payload: res, Txid: msg.Txid, ChannelId: msg.ChannelId}
@@ -643,7 +643,7 @@ func (h *Handler) handleGetStateByRange(msg *pb.ChaincodeMessage) {
643643

644644
const maxResultLimit = 100
645645

646-
//getQueryResponse takes an iterator and fetch state to construct QueryResponse
646+
// getQueryResponse takes an iterator and fetch state to construct QueryResponse
647647
func getQueryResponse(txContext *TransactionContext, iter commonledger.ResultsIterator, iterID string) (*pb.QueryResponse, error) {
648648
pendingQueryResults := txContext.pendingQueryResults[iterID]
649649
for {
@@ -944,8 +944,8 @@ func isCollectionSet(collection string) bool {
944944
}
945945

946946
func (h *Handler) getTxContextForMessage(channelID string, txid string, msgType string, payload []byte, fmtStr string, args ...interface{}) (*TransactionContext, *pb.ChaincodeMessage) {
947-
//if we have a channelID, just get the txsim from isValidTxSim
948-
//if this is NOT an INVOKE_CHAINCODE, then let isValidTxSim handle retrieving the txContext
947+
// if we have a channelID, just get the txsim from isValidTxSim
948+
// if this is NOT an INVOKE_CHAINCODE, then let isValidTxSim handle retrieving the txContext
949949
if channelID != "" || msgType != pb.ChaincodeMessage_INVOKE_CHAINCODE.String() {
950950
return h.isValidTxSim(channelID, txid, fmtStr, args)
951951
}
@@ -1109,12 +1109,12 @@ func (h *Handler) handleModState(msg *pb.ChaincodeMessage) {
11091109
chaincodeLogger.Debugf("[%s] getting chaincode data for %s on channel %s",
11101110
shorttxid(msg.Txid), calledCcIns.ChaincodeName, calledCcIns.ChainID)
11111111

1112-
//is the chaincode a system chaincode ?
1112+
// is the chaincode a system chaincode ?
11131113
isscc := h.sccp.IsSysCC(calledCcIns.ChaincodeName)
11141114

11151115
var version string
11161116
if !isscc {
1117-
//if its a user chaincode, get the details
1117+
// if its a user chaincode, get the details
11181118
cd, err := h.lifecycle.GetChaincodeDefinition(ctxt, msg.Txid, txContext.signedProp, txContext.proposal, calledCcIns.ChainID, calledCcIns.ChaincodeName)
11191119
if err != nil {
11201120
errHandler([]byte(err.Error()), "[%s]Failed to get chaincode data (%s) for invoked chaincode. Sending %s", shorttxid(msg.Txid), err, pb.ChaincodeMessage_ERROR)
@@ -1129,7 +1129,7 @@ func (h *Handler) handleModState(msg *pb.ChaincodeMessage) {
11291129
return
11301130
}
11311131
} else {
1132-
//this is a system cc, just call it directly
1132+
// this is a system cc, just call it directly
11331133
version = util.GetSysCCVersion()
11341134
}
11351135

@@ -1155,8 +1155,8 @@ func (h *Handler) handleModState(msg *pb.ChaincodeMessage) {
11551155
// Execute the chaincode... this CANNOT be an init at least for now
11561156
response, execErr := h.handlerSupport.execute(ctxt, cccid, ccMsg)
11571157

1158-
//payload is marshalled and send to the calling chaincode's shim which unmarshals and
1159-
//sends it to chaincode
1158+
// payload is marshalled and send to the calling chaincode's shim which unmarshals and
1159+
// sends it to chaincode
11601160
res = nil
11611161
if execErr != nil {
11621162
err = execErr
@@ -1206,8 +1206,8 @@ func (h *Handler) Execute(ctxt context.Context, cccid *ccprovider.CCContext, msg
12061206
var ccresp *pb.ChaincodeMessage
12071207
select {
12081208
case ccresp = <-notfy:
1209-
//response is sent to user or calling chaincode. ChaincodeMessage_ERROR
1210-
//are typically treated as error
1209+
// response is sent to user or calling chaincode. ChaincodeMessage_ERROR
1210+
// are typically treated as error
12111211
case <-time.After(timeout):
12121212
err = errors.New("timeout expired while executing transaction")
12131213
}
@@ -1225,7 +1225,7 @@ func (h *Handler) sendExecuteMessage(ctxt context.Context, chainID string, msg *
12251225
}
12261226
chaincodeLogger.Debugf("[%s]Inside sendExecuteMessage. Message %s", shorttxid(msg.Txid), msg.Type)
12271227

1228-
//if security is disabled the context elements will just be nil
1228+
// if security is disabled the context elements will just be nil
12291229
if err = h.setChaincodeProposal(signedProp, prop, msg); err != nil {
12301230
return nil, err
12311231
}

0 commit comments

Comments
 (0)