@@ -371,9 +371,7 @@ func (stub *ChaincodeStub) GetTxID() string {
371
371
372
372
// ------------- Call Chaincode functions ---------------
373
373
374
- // InvokeChaincode locally calls the specified chaincode `Invoke` using the
375
- // same transaction context; that is, chaincode calling chaincode doesn't
376
- // create a new transaction message.
374
+ // InvokeChaincode documentation can be found in interfaces.go
377
375
func (stub * ChaincodeStub ) InvokeChaincode (chaincodeName string , args [][]byte , channel string ) pb.Response {
378
376
// Internally we handle chaincode name as a composite name
379
377
if channel != "" {
@@ -384,45 +382,38 @@ func (stub *ChaincodeStub) InvokeChaincode(chaincodeName string, args [][]byte,
384
382
385
383
// --------- State functions ----------
386
384
387
- // GetState returns the byte array value specified by the `key`.
385
+ // GetState documentation can be found in interfaces.go
388
386
func (stub * ChaincodeStub ) GetState (key string ) ([]byte , error ) {
389
387
return stub .handler .handleGetState (key , stub .TxID )
390
388
}
391
389
392
- // PutState writes the specified `value` and `key` into the ledger.
393
- // Simple keys must not be an empty string and must not start with null
394
- // character (0x00), in order to avoid range query collisions with
395
- // composite keys, which internally get prefixed with 0x00 as composite
396
- // key namespace.
390
+ // PutState documentation can be found in interfaces.go
397
391
func (stub * ChaincodeStub ) PutState (key string , value []byte ) error {
398
392
if key == "" {
399
393
return fmt .Errorf ("key must not be an empty string" )
400
394
}
401
395
return stub .handler .handlePutState (key , value , stub .TxID )
402
396
}
403
397
404
- // DelState removes the specified `key` and its value from the ledger.
398
+ // DelState documentation can be found in interfaces.go
405
399
func (stub * ChaincodeStub ) DelState (key string ) error {
406
400
return stub .handler .handleDelState (key , stub .TxID )
407
401
}
408
402
409
- // CommonIterator allows a chaincode to iterate over a set of
410
- // key/value pairs in the state.
403
+ // CommonIterator documentation can be found in interfaces.go
411
404
type CommonIterator struct {
412
405
handler * Handler
413
406
uuid string
414
407
response * pb.QueryResponse
415
408
currentLoc int
416
409
}
417
410
418
- //GeneralQueryIterator allows a chaincode to iterate the result
419
- //of range and execute query.
411
+ // StateQueryIterator documentation can be found in interfaces.go
420
412
type StateQueryIterator struct {
421
413
* CommonIterator
422
414
}
423
415
424
- //GeneralQueryIterator allows a chaincode to iterate the result
425
- //of history query.
416
+ // HistoryQueryIterator documentation can be found in interfaces.go
426
417
type HistoryQueryIterator struct {
427
418
* CommonIterator
428
419
}
@@ -442,13 +433,7 @@ func (stub *ChaincodeStub) handleGetStateByRange(startKey, endKey string) (State
442
433
return & StateQueryIterator {CommonIterator : & CommonIterator {stub .handler , stub .TxID , response , 0 }}, nil
443
434
}
444
435
445
- // GetStateByRange function can be invoked by a chaincode to query of a range
446
- // of keys in the state. Assuming the startKey and endKey are in lexical order,
447
- // an iterator will be returned that can be used to iterate over all keys
448
- // between the startKey and endKey. The startKey is inclusive whereas the endKey
449
- // is exclusive. The keys are returned by the iterator in lexical order. Note
450
- // that startKey and endKey can be empty string, which implies unbounded range
451
- // query on start or end.
436
+ // GetStateByRange documentation can be found in interfaces.go
452
437
func (stub * ChaincodeStub ) GetStateByRange (startKey , endKey string ) (StateQueryIteratorInterface , error ) {
453
438
if startKey == "" {
454
439
startKey = emptyKeySubstitute
@@ -459,11 +444,7 @@ func (stub *ChaincodeStub) GetStateByRange(startKey, endKey string) (StateQueryI
459
444
return stub .handleGetStateByRange (startKey , endKey )
460
445
}
461
446
462
- // GetQueryResult function can be invoked by a chaincode to perform a
463
- // rich query against state database. Only supported by state database implementations
464
- // that support rich query. The query string is in the syntax of the underlying
465
- // state database. An iterator is returned which can be used to iterate (next) over
466
- // the query result set
447
+ // GetQueryResult documentation can be found in interfaces.go
467
448
func (stub * ChaincodeStub ) GetQueryResult (query string ) (StateQueryIteratorInterface , error ) {
468
449
response , err := stub .handler .handleGetQueryResult (query , stub .TxID )
469
450
if err != nil {
@@ -472,8 +453,7 @@ func (stub *ChaincodeStub) GetQueryResult(query string) (StateQueryIteratorInter
472
453
return & StateQueryIterator {CommonIterator : & CommonIterator {stub .handler , stub .TxID , response , 0 }}, nil
473
454
}
474
455
475
- // GetHistoryForKey function can be invoked by a chaincode to return a history of
476
- // key values across time. GetHistoryForKey is intended to be used for read-only queries.
456
+ // GetHistoryForKey documentation can be found in interfaces.go
477
457
func (stub * ChaincodeStub ) GetHistoryForKey (key string ) (HistoryQueryIteratorInterface , error ) {
478
458
response , err := stub .handler .handleGetHistoryForKey (key , stub .TxID )
479
459
if err != nil {
@@ -482,12 +462,12 @@ func (stub *ChaincodeStub) GetHistoryForKey(key string) (HistoryQueryIteratorInt
482
462
return & HistoryQueryIterator {CommonIterator : & CommonIterator {stub .handler , stub .TxID , response , 0 }}, nil
483
463
}
484
464
485
- //CreateCompositeKey combines the given attributes to form a composite key.
465
+ //CreateCompositeKey documentation can be found in interfaces.go
486
466
func (stub * ChaincodeStub ) CreateCompositeKey (objectType string , attributes []string ) (string , error ) {
487
467
return createCompositeKey (objectType , attributes )
488
468
}
489
469
490
- //SplitCompositeKey splits the key into attributes on which the composite key was formed.
470
+ //SplitCompositeKey documentation can be found in interfaces.go
491
471
func (stub * ChaincodeStub ) SplitCompositeKey (compositeKey string ) (string , []string , error ) {
492
472
return splitCompositeKey (compositeKey )
493
473
}
@@ -574,8 +554,7 @@ func (iter *HistoryQueryIterator) Next() (*queryresult.KeyModification, error) {
574
554
}
575
555
}
576
556
577
- // HasNext returns true if the range query iterator contains additional keys
578
- // and values.
557
+ // HasNext documentation can be found in interfaces.go
579
558
func (iter * CommonIterator ) HasNext () bool {
580
559
if iter .currentLoc < len (iter .response .Results ) || iter .response .HasMore {
581
560
return true
@@ -649,19 +628,18 @@ func (iter *CommonIterator) nextResult(rType resultType) (commonledger.QueryResu
649
628
return nil , errors .New ("Invalid iterator state" )
650
629
}
651
630
652
- // Close closes the range query iterator. This should be called when done
653
- // reading from the iterator to free up resources.
631
+ // Close documentation can be found in interfaces.go
654
632
func (iter * CommonIterator ) Close () error {
655
633
_ , err := iter .handler .handleQueryStateClose (iter .response .Id , iter .uuid )
656
634
return err
657
635
}
658
636
659
- // GetArgs returns the argument list
637
+ // GetArgs documentation can be found in interfaces.go
660
638
func (stub * ChaincodeStub ) GetArgs () [][]byte {
661
639
return stub .args
662
640
}
663
641
664
- // GetStringArgs returns the arguments as array of strings
642
+ // GetStringArgs documentation can be found in interfaces.go
665
643
func (stub * ChaincodeStub ) GetStringArgs () []string {
666
644
args := stub .GetArgs ()
667
645
strargs := make ([]string , 0 , len (args ))
@@ -671,8 +649,7 @@ func (stub *ChaincodeStub) GetStringArgs() []string {
671
649
return strargs
672
650
}
673
651
674
- // GetFunctionAndParameters returns the first arg as the function and the rest
675
- // as argument string array
652
+ // GetFunctionAndParameters documentation can be found in interfaces.go
676
653
func (stub * ChaincodeStub ) GetFunctionAndParameters () (function string , params []string ) {
677
654
allargs := stub .GetStringArgs ()
678
655
function = ""
@@ -684,32 +661,27 @@ func (stub *ChaincodeStub) GetFunctionAndParameters() (function string, params [
684
661
return
685
662
}
686
663
687
- // GetCreator returns SignatureHeader.Creator of the signedProposal
688
- // this Stub refers to.
664
+ // GetCreator documentation can be found in interfaces.go
689
665
func (stub * ChaincodeStub ) GetCreator () ([]byte , error ) {
690
666
return stub .creator , nil
691
667
}
692
668
693
- // GetTransient returns the ChaincodeProposalPayload.transient field.
694
- // It is a map that contains data (e.g. cryptographic material)
695
- // that might be used to implement some form of application-level confidentiality. The contents
696
- // of this field, as prescribed by ChaincodeProposalPayload, are supposed to always
697
- // be omitted from the transaction and excluded from the ledger.
669
+ // GetTransient documentation can be found in interfaces.go
698
670
func (stub * ChaincodeStub ) GetTransient () (map [string ][]byte , error ) {
699
671
return stub .transient , nil
700
672
}
701
673
702
- // GetBinding returns the transaction binding
674
+ // GetBinding documentation can be found in interfaces.go
703
675
func (stub * ChaincodeStub ) GetBinding () ([]byte , error ) {
704
676
return stub .binding , nil
705
677
}
706
678
707
- // GetSignedProposal return the signed signedProposal this stub refers to.
679
+ // GetSignedProposal documentation can be found in interfaces.go
708
680
func (stub * ChaincodeStub ) GetSignedProposal () (* pb.SignedProposal , error ) {
709
681
return stub .signedProposal , nil
710
682
}
711
683
712
- // GetArgsSlice returns the arguments to the stub call as a byte array
684
+ // GetArgsSlice documentation can be found in interfaces.go
713
685
func (stub * ChaincodeStub ) GetArgsSlice () ([]byte , error ) {
714
686
args := stub .GetArgs ()
715
687
res := []byte {}
@@ -719,9 +691,7 @@ func (stub *ChaincodeStub) GetArgsSlice() ([]byte, error) {
719
691
return res , nil
720
692
}
721
693
722
- // GetTxTimestamp returns the timestamp when the transaction was created. This
723
- // is taken from the transaction ChannelHeader, so it will be the same across
724
- // all endorsers.
694
+ // GetTxTimestamp documentation can be found in interfaces.go
725
695
func (stub * ChaincodeStub ) GetTxTimestamp () (* timestamp.Timestamp , error ) {
726
696
hdr , err := utils .GetHeader (stub .proposal .Header )
727
697
if err != nil {
@@ -737,7 +707,7 @@ func (stub *ChaincodeStub) GetTxTimestamp() (*timestamp.Timestamp, error) {
737
707
738
708
// ------------- ChaincodeEvent API ----------------------
739
709
740
- // SetEvent saves the event to be sent when a transaction is made part of a block
710
+ // SetEvent documentation can be found in interfaces.go
741
711
func (stub * ChaincodeStub ) SetEvent (name string , payload []byte ) error {
742
712
if name == "" {
743
713
return errors .New ("Event name can not be nil string." )
0 commit comments