@@ -203,23 +203,23 @@ func (h *Handler) handleInit(msg *pb.ChaincodeMessage, errc chan error) {
203
203
// Get the function and args from Payload
204
204
input := & pb.ChaincodeInput {}
205
205
unmarshalErr := proto .Unmarshal (msg .Payload , input )
206
- if nextStateMsg = errFunc (unmarshalErr , nil , nil , "[%s] Incorrect payload format. Sending %s" , shorttxid (msg .Txid ), pb .ChaincodeMessage_ERROR . String () ); nextStateMsg != nil {
206
+ if nextStateMsg = errFunc (unmarshalErr , nil , nil , "[%s] Incorrect payload format. Sending %s" , shorttxid (msg .Txid ), pb .ChaincodeMessage_ERROR ); nextStateMsg != nil {
207
207
return
208
208
}
209
209
210
210
// Call chaincode's Run
211
211
// Create the ChaincodeStub which the chaincode can use to callback
212
212
stub := new (ChaincodeStub )
213
213
err := stub .init (h , msg .ChannelId , msg .Txid , input , msg .Proposal )
214
- if nextStateMsg = errFunc (err , nil , stub .chaincodeEvent , "[%s] Init get error response. Sending %s" , shorttxid (msg .Txid ), pb .ChaincodeMessage_ERROR . String () ); nextStateMsg != nil {
214
+ if nextStateMsg = errFunc (err , nil , stub .chaincodeEvent , "[%s] Init get error response. Sending %s" , shorttxid (msg .Txid ), pb .ChaincodeMessage_ERROR ); nextStateMsg != nil {
215
215
return
216
216
}
217
217
res := h .cc .Init (stub )
218
218
chaincodeLogger .Debugf ("[%s] Init get response status: %d" , shorttxid (msg .Txid ), res .Status )
219
219
220
220
if res .Status >= ERROR {
221
221
err = errors .New (res .Message )
222
- if nextStateMsg = errFunc (err , []byte (res .Message ), stub .chaincodeEvent , "[%s] Init get error response. Sending %s" , shorttxid (msg .Txid ), pb .ChaincodeMessage_ERROR . String () ); nextStateMsg != nil {
222
+ if nextStateMsg = errFunc (err , []byte (res .Message ), stub .chaincodeEvent , "[%s] Init get error response. Sending %s" , shorttxid (msg .Txid ), pb .ChaincodeMessage_ERROR ); nextStateMsg != nil {
223
223
return
224
224
}
225
225
}
@@ -263,22 +263,22 @@ func (h *Handler) handleTransaction(msg *pb.ChaincodeMessage, errc chan error) {
263
263
// Get the function and args from Payload
264
264
input := & pb.ChaincodeInput {}
265
265
unmarshalErr := proto .Unmarshal (msg .Payload , input )
266
- if nextStateMsg = errFunc (unmarshalErr , nil , "[%s] Incorrect payload format. Sending %s" , shorttxid (msg .Txid ), pb .ChaincodeMessage_ERROR . String () ); nextStateMsg != nil {
266
+ if nextStateMsg = errFunc (unmarshalErr , nil , "[%s] Incorrect payload format. Sending %s" , shorttxid (msg .Txid ), pb .ChaincodeMessage_ERROR ); nextStateMsg != nil {
267
267
return
268
268
}
269
269
270
270
// Call chaincode's Run
271
271
// Create the ChaincodeStub which the chaincode can use to callback
272
272
stub := new (ChaincodeStub )
273
273
err := stub .init (h , msg .ChannelId , msg .Txid , input , msg .Proposal )
274
- if nextStateMsg = errFunc (err , stub .chaincodeEvent , "[%s] Transaction execution failed. Sending %s" , shorttxid (msg .Txid ), pb .ChaincodeMessage_ERROR . String () ); nextStateMsg != nil {
274
+ if nextStateMsg = errFunc (err , stub .chaincodeEvent , "[%s] Transaction execution failed. Sending %s" , shorttxid (msg .Txid ), pb .ChaincodeMessage_ERROR ); nextStateMsg != nil {
275
275
return
276
276
}
277
277
res := h .cc .Invoke (stub )
278
278
279
279
// Endorser will handle error contained in Response.
280
280
resBytes , err := proto .Marshal (& res )
281
- if nextStateMsg = errFunc (err , stub .chaincodeEvent , "[%s] Transaction execution failed. Sending %s" , shorttxid (msg .Txid ), pb .ChaincodeMessage_ERROR . String () ); nextStateMsg != nil {
281
+ if nextStateMsg = errFunc (err , stub .chaincodeEvent , "[%s] Transaction execution failed. Sending %s" , shorttxid (msg .Txid ), pb .ChaincodeMessage_ERROR ); nextStateMsg != nil {
282
282
return
283
283
}
284
284
@@ -315,12 +315,12 @@ func (h *Handler) handleGetState(collection string, key string, channelId string
315
315
return nil , errors .WithMessage (err , fmt .Sprintf ("[%s] error sending %s" , shorttxid (txid ), pb .ChaincodeMessage_GET_STATE ))
316
316
}
317
317
318
- if responseMsg .Type . String () == pb .ChaincodeMessage_RESPONSE . String () {
318
+ if responseMsg .Type == pb .ChaincodeMessage_RESPONSE {
319
319
// Success response
320
320
chaincodeLogger .Debugf ("[%s] GetState received payload %s" , shorttxid (responseMsg .Txid ), pb .ChaincodeMessage_RESPONSE )
321
321
return responseMsg .Payload , nil
322
322
}
323
- if responseMsg .Type . String () == pb .ChaincodeMessage_ERROR . String () {
323
+ if responseMsg .Type == pb .ChaincodeMessage_ERROR {
324
324
// Error response
325
325
chaincodeLogger .Errorf ("[%s] GetState received error %s" , shorttxid (responseMsg .Txid ), pb .ChaincodeMessage_ERROR )
326
326
return nil , errors .New (string (responseMsg .Payload [:]))
@@ -343,12 +343,12 @@ func (h *Handler) handleGetPrivateDataHash(collection string, key string, channe
343
343
return nil , errors .WithMessage (err , fmt .Sprintf ("[%s] error sending %s" , shorttxid (txid ), pb .ChaincodeMessage_GET_PRIVATE_DATA_HASH ))
344
344
}
345
345
346
- if responseMsg .Type . String () == pb .ChaincodeMessage_RESPONSE . String () {
346
+ if responseMsg .Type == pb .ChaincodeMessage_RESPONSE {
347
347
// Success response
348
348
chaincodeLogger .Debugf ("[%s] GetPrivateDataHash received payload %s" , shorttxid (responseMsg .Txid ), pb .ChaincodeMessage_RESPONSE )
349
349
return responseMsg .Payload , nil
350
350
}
351
- if responseMsg .Type . String () == pb .ChaincodeMessage_ERROR . String () {
351
+ if responseMsg .Type == pb .ChaincodeMessage_ERROR {
352
352
// Error response
353
353
chaincodeLogger .Errorf ("[%s] GetPrivateDataHash received error %s" , shorttxid (responseMsg .Txid ), pb .ChaincodeMessage_ERROR )
354
354
return nil , errors .New (string (responseMsg .Payload [:]))
@@ -371,7 +371,7 @@ func (h *Handler) handleGetStateMetadata(collection string, key string, channelI
371
371
return nil , errors .WithMessage (err , fmt .Sprintf ("[%s] error sending %s" , shorttxid (txID ), pb .ChaincodeMessage_GET_STATE_METADATA ))
372
372
}
373
373
374
- if responseMsg .Type . String () == pb .ChaincodeMessage_RESPONSE . String () {
374
+ if responseMsg .Type == pb .ChaincodeMessage_RESPONSE {
375
375
// Success response
376
376
chaincodeLogger .Debugf ("[%s]GetStateMetadata received payload %s" , shorttxid (responseMsg .Txid ), pb .ChaincodeMessage_RESPONSE )
377
377
var mdResult pb.StateMetadataResult
@@ -387,7 +387,7 @@ func (h *Handler) handleGetStateMetadata(collection string, key string, channelI
387
387
388
388
return metadata , nil
389
389
}
390
- if responseMsg .Type . String () == pb .ChaincodeMessage_ERROR . String () {
390
+ if responseMsg .Type == pb .ChaincodeMessage_ERROR {
391
391
// Error response
392
392
chaincodeLogger .Errorf ("[%s]GetStateMetadata received error %s" , shorttxid (responseMsg .Txid ), pb .ChaincodeMessage_ERROR )
393
393
return nil , errors .New (string (responseMsg .Payload [:]))
@@ -413,13 +413,13 @@ func (h *Handler) handlePutState(collection string, key string, value []byte, ch
413
413
return errors .WithMessage (err , fmt .Sprintf ("[%s] error sending %s" , msg .Txid , pb .ChaincodeMessage_PUT_STATE ))
414
414
}
415
415
416
- if responseMsg .Type . String () == pb .ChaincodeMessage_RESPONSE . String () {
416
+ if responseMsg .Type == pb .ChaincodeMessage_RESPONSE {
417
417
// Success response
418
418
chaincodeLogger .Debugf ("[%s] Received %s. Successfully updated state" , shorttxid (responseMsg .Txid ), pb .ChaincodeMessage_RESPONSE )
419
419
return nil
420
420
}
421
421
422
- if responseMsg .Type . String () == pb .ChaincodeMessage_ERROR . String () {
422
+ if responseMsg .Type == pb .ChaincodeMessage_ERROR {
423
423
// Error response
424
424
chaincodeLogger .Errorf ("[%s] Received %s. Payload: %s" , shorttxid (responseMsg .Txid ), pb .ChaincodeMessage_ERROR , responseMsg .Payload )
425
425
return errors .New (string (responseMsg .Payload [:]))
@@ -444,13 +444,13 @@ func (h *Handler) handlePutStateMetadataEntry(collection string, key string, met
444
444
return errors .WithMessage (err , fmt .Sprintf ("[%s] error sending %s" , msg .Txid , pb .ChaincodeMessage_PUT_STATE_METADATA ))
445
445
}
446
446
447
- if responseMsg .Type . String () == pb .ChaincodeMessage_RESPONSE . String () {
447
+ if responseMsg .Type == pb .ChaincodeMessage_RESPONSE {
448
448
// Success response
449
449
chaincodeLogger .Debugf ("[%s]Received %s. Successfully updated state metadata" , shorttxid (responseMsg .Txid ), pb .ChaincodeMessage_RESPONSE )
450
450
return nil
451
451
}
452
452
453
- if responseMsg .Type . String () == pb .ChaincodeMessage_ERROR . String () {
453
+ if responseMsg .Type == pb .ChaincodeMessage_ERROR {
454
454
// Error response
455
455
chaincodeLogger .Errorf ("[%s]Received %s. Payload: %s" , shorttxid (responseMsg .Txid ), pb .ChaincodeMessage_ERROR , responseMsg .Payload )
456
456
return errors .New (string (responseMsg .Payload [:]))
@@ -475,12 +475,12 @@ func (h *Handler) handleDelState(collection string, key string, channelId string
475
475
return errors .Errorf ("[%s] error sending %s" , shorttxid (msg .Txid ), pb .ChaincodeMessage_DEL_STATE )
476
476
}
477
477
478
- if responseMsg .Type . String () == pb .ChaincodeMessage_RESPONSE . String () {
478
+ if responseMsg .Type == pb .ChaincodeMessage_RESPONSE {
479
479
// Success response
480
480
chaincodeLogger .Debugf ("[%s] Received %s. Successfully deleted state" , msg .Txid , pb .ChaincodeMessage_RESPONSE )
481
481
return nil
482
482
}
483
- if responseMsg .Type . String () == pb .ChaincodeMessage_ERROR . String () {
483
+ if responseMsg .Type == pb .ChaincodeMessage_ERROR {
484
484
// Error response
485
485
chaincodeLogger .Errorf ("[%s] Received %s. Payload: %s" , msg .Txid , pb .ChaincodeMessage_ERROR , responseMsg .Payload )
486
486
return errors .New (string (responseMsg .Payload [:]))
@@ -505,7 +505,7 @@ func (h *Handler) handleGetStateByRange(collection, startKey, endKey string, met
505
505
return nil , errors .Errorf ("[%s] error sending %s" , shorttxid (msg .Txid ), pb .ChaincodeMessage_GET_STATE_BY_RANGE )
506
506
}
507
507
508
- if responseMsg .Type . String () == pb .ChaincodeMessage_RESPONSE . String () {
508
+ if responseMsg .Type == pb .ChaincodeMessage_RESPONSE {
509
509
// Success response
510
510
chaincodeLogger .Debugf ("[%s] Received %s. Successfully got range" , shorttxid (responseMsg .Txid ), pb .ChaincodeMessage_RESPONSE )
511
511
@@ -518,7 +518,7 @@ func (h *Handler) handleGetStateByRange(collection, startKey, endKey string, met
518
518
519
519
return rangeQueryResponse , nil
520
520
}
521
- if responseMsg .Type . String () == pb .ChaincodeMessage_ERROR . String () {
521
+ if responseMsg .Type == pb .ChaincodeMessage_ERROR {
522
522
// Error response
523
523
chaincodeLogger .Errorf ("[%s] Received %s" , shorttxid (responseMsg .Txid ), pb .ChaincodeMessage_ERROR )
524
524
return nil , errors .New (string (responseMsg .Payload [:]))
@@ -552,7 +552,7 @@ func (h *Handler) handleQueryStateNext(id, channelId, txid string) (*pb.QueryRes
552
552
return nil , errors .Errorf ("[%s] error sending %s" , shorttxid (msg .Txid ), pb .ChaincodeMessage_QUERY_STATE_NEXT )
553
553
}
554
554
555
- if responseMsg .Type . String () == pb .ChaincodeMessage_RESPONSE . String () {
555
+ if responseMsg .Type == pb .ChaincodeMessage_RESPONSE {
556
556
// Success response
557
557
chaincodeLogger .Debugf ("[%s] Received %s. Successfully got range" , shorttxid (responseMsg .Txid ), pb .ChaincodeMessage_RESPONSE )
558
558
@@ -564,7 +564,7 @@ func (h *Handler) handleQueryStateNext(id, channelId, txid string) (*pb.QueryRes
564
564
565
565
return queryResponse , nil
566
566
}
567
- if responseMsg .Type . String () == pb .ChaincodeMessage_ERROR . String () {
567
+ if responseMsg .Type == pb .ChaincodeMessage_ERROR {
568
568
// Error response
569
569
chaincodeLogger .Errorf ("[%s] Received %s" , shorttxid (responseMsg .Txid ), pb .ChaincodeMessage_ERROR )
570
570
return nil , errors .New (string (responseMsg .Payload [:]))
@@ -598,7 +598,7 @@ func (h *Handler) handleQueryStateClose(id, channelId, txid string) (*pb.QueryRe
598
598
return nil , errors .Errorf ("[%s] error sending %s" , shorttxid (msg .Txid ), pb .ChaincodeMessage_QUERY_STATE_CLOSE )
599
599
}
600
600
601
- if responseMsg .Type . String () == pb .ChaincodeMessage_RESPONSE . String () {
601
+ if responseMsg .Type == pb .ChaincodeMessage_RESPONSE {
602
602
// Success response
603
603
chaincodeLogger .Debugf ("[%s] Received %s. Successfully got range" , shorttxid (responseMsg .Txid ), pb .ChaincodeMessage_RESPONSE )
604
604
@@ -610,7 +610,7 @@ func (h *Handler) handleQueryStateClose(id, channelId, txid string) (*pb.QueryRe
610
610
611
611
return queryResponse , nil
612
612
}
613
- if responseMsg .Type . String () == pb .ChaincodeMessage_ERROR . String () {
613
+ if responseMsg .Type == pb .ChaincodeMessage_ERROR {
614
614
// Error response
615
615
chaincodeLogger .Errorf ("[%s] Received %s" , shorttxid (responseMsg .Txid ), pb .ChaincodeMessage_ERROR )
616
616
return nil , errors .New (string (responseMsg .Payload [:]))
@@ -635,7 +635,7 @@ func (h *Handler) handleGetQueryResult(collection string, query string, metadata
635
635
return nil , errors .Errorf ("[%s] error sending %s" , shorttxid (msg .Txid ), pb .ChaincodeMessage_GET_QUERY_RESULT )
636
636
}
637
637
638
- if responseMsg .Type . String () == pb .ChaincodeMessage_RESPONSE . String () {
638
+ if responseMsg .Type == pb .ChaincodeMessage_RESPONSE {
639
639
// Success response
640
640
chaincodeLogger .Debugf ("[%s] Received %s. Successfully got range" , shorttxid (responseMsg .Txid ), pb .ChaincodeMessage_RESPONSE )
641
641
@@ -647,7 +647,7 @@ func (h *Handler) handleGetQueryResult(collection string, query string, metadata
647
647
648
648
return executeQueryResponse , nil
649
649
}
650
- if responseMsg .Type . String () == pb .ChaincodeMessage_ERROR . String () {
650
+ if responseMsg .Type == pb .ChaincodeMessage_ERROR {
651
651
// Error response
652
652
chaincodeLogger .Errorf ("[%s] Received %s" , shorttxid (responseMsg .Txid ), pb .ChaincodeMessage_ERROR )
653
653
return nil , errors .New (string (responseMsg .Payload [:]))
@@ -681,7 +681,7 @@ func (h *Handler) handleGetHistoryForKey(key string, channelId string, txid stri
681
681
return nil , errors .Errorf ("[%s] error sending %s" , shorttxid (msg .Txid ), pb .ChaincodeMessage_GET_HISTORY_FOR_KEY )
682
682
}
683
683
684
- if responseMsg .Type . String () == pb .ChaincodeMessage_RESPONSE . String () {
684
+ if responseMsg .Type == pb .ChaincodeMessage_RESPONSE {
685
685
// Success response
686
686
chaincodeLogger .Debugf ("[%s] Received %s. Successfully got range" , shorttxid (responseMsg .Txid ), pb .ChaincodeMessage_RESPONSE )
687
687
@@ -693,7 +693,7 @@ func (h *Handler) handleGetHistoryForKey(key string, channelId string, txid stri
693
693
694
694
return getHistoryForKeyResponse , nil
695
695
}
696
- if responseMsg .Type . String () == pb .ChaincodeMessage_ERROR . String () {
696
+ if responseMsg .Type == pb .ChaincodeMessage_ERROR {
697
697
// Error response
698
698
chaincodeLogger .Errorf ("[%s] Received %s" , shorttxid (responseMsg .Txid ), pb .ChaincodeMessage_ERROR )
699
699
return nil , errors .New (string (responseMsg .Payload [:]))
@@ -732,7 +732,7 @@ func (h *Handler) handleInvokeChaincode(chaincodeName string, args [][]byte, cha
732
732
return h .createResponse (ERROR , []byte (errStr ))
733
733
}
734
734
735
- if responseMsg .Type . String () == pb .ChaincodeMessage_RESPONSE . String () {
735
+ if responseMsg .Type == pb .ChaincodeMessage_RESPONSE {
736
736
// Success response
737
737
chaincodeLogger .Debugf ("[%s] Received %s. Successfully invoked chaincode" , shorttxid (responseMsg .Txid ), pb .ChaincodeMessage_RESPONSE )
738
738
respMsg := & pb.ChaincodeMessage {}
@@ -753,7 +753,7 @@ func (h *Handler) handleInvokeChaincode(chaincodeName string, args [][]byte, cha
753
753
chaincodeLogger .Errorf ("[%s] Received %s. Error from chaincode" , shorttxid (responseMsg .Txid ), respMsg .Type )
754
754
return h .createResponse (ERROR , responseMsg .Payload )
755
755
}
756
- if responseMsg .Type . String () == pb .ChaincodeMessage_ERROR . String () {
756
+ if responseMsg .Type == pb .ChaincodeMessage_ERROR {
757
757
// Error response
758
758
chaincodeLogger .Errorf ("[%s] Received %s." , shorttxid (responseMsg .Txid ), pb .ChaincodeMessage_ERROR )
759
759
return h .createResponse (ERROR , responseMsg .Payload )
0 commit comments