Skip to content

Commit d5467f3

Browse files
committed
[FAB-204] Expose ledger rich query API to chaincode
Adding a new chaincode API called ExecuteQuery() that executes a given rich query on the state DB (if it is supported). For example, if CouchDB is the state DB, chaincode can utilize ExecuteQuery() API to execute declarative JSON query to find documents which satisfy given criteria. http://docs.couchdb.org/en/2.0.0/api/database/find.html Change-Id: I296d261c247badc679a7d5bfa25172a9e19ccf34 Signed-off-by: senthil <[email protected]>
1 parent dffcaf4 commit d5467f3

File tree

12 files changed

+514
-242
lines changed

12 files changed

+514
-242
lines changed

core/chaincode/chaincode_support.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ func (chaincodeSupport *ChaincodeSupport) deregisterHandler(chaincodehandler *Ha
298298

299299
// clean up rangeQueryIteratorMap
300300
for _, context := range chaincodehandler.txCtxs {
301-
for _, v := range context.rangeQueryIteratorMap {
301+
for _, v := range context.queryIteratorMap {
302302
v.Close()
303303
}
304304
}

core/chaincode/exectransaction_test.go

+54-4
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import (
3737
putils "github.com/hyperledger/fabric/protos/utils"
3838

3939
"github.com/golang/protobuf/proto"
40+
"github.com/hyperledger/fabric/core/ledger/ledgerconfig"
4041
"github.com/hyperledger/fabric/core/ledger/ledgermgmt"
4142
"github.com/hyperledger/fabric/msp"
4243
mspmgmt "github.com/hyperledger/fabric/msp/mgmt"
@@ -855,9 +856,7 @@ func TestChaincodeInvokeChaincodeErrorCase(t *testing.T) {
855856
}
856857

857858
// Test the invocation of a transaction.
858-
func TestRangeQuery(t *testing.T) {
859-
//TODO enable after ledger enables RangeQuery
860-
t.Skip()
859+
func TestQueries(t *testing.T) {
861860

862861
chainID := util.GetTestChainID()
863862

@@ -891,8 +890,44 @@ func TestRangeQuery(t *testing.T) {
891890
}
892891

893892
// Invoke second chaincode, which will inturn invoke the first chaincode
893+
f = "put"
894+
args = util.ToChaincodeArgs(f, "key1", "{\"shipmentID\":\"161003PKC7300\",\"customsInvoice\":{\"methodOfTransport\":\"GROUND\",\"invoiceNumber\":\"00091622\"},\"weightUnitOfMeasure\":\"KGM\",\"volumeUnitOfMeasure\": \"CO\",\"dimensionUnitOfMeasure\":\"CM\",\"currency\":\"USD\"}")
895+
spec = &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID, Input: &pb.ChaincodeInput{Args: args}}
896+
_, _, _, err = invoke(ctxt, chainID, spec)
897+
898+
if err != nil {
899+
t.Fail()
900+
t.Logf("Error invoking <%s>: %s", chaincodeID, err)
901+
theChaincodeSupport.Stop(ctxt, cccid, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec})
902+
return
903+
}
904+
905+
f = "put"
906+
args = util.ToChaincodeArgs(f, "key2", "{\"shipmentID\":\"161003PKC7300\",\"customsInvoice\":{\"methodOfTransport\":\"GROUND\",\"invoiceNumber\":\"00091622\"},\"weightUnitOfMeasure\":\"KGM\",\"volumeUnitOfMeasure\": \"CO\",\"dimensionUnitOfMeasure\":\"CM\",\"currency\":\"USD\"}")
907+
spec = &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID, Input: &pb.ChaincodeInput{Args: args}}
908+
_, _, _, err = invoke(ctxt, chainID, spec)
909+
910+
if err != nil {
911+
t.Fail()
912+
t.Logf("Error invoking <%s>: %s", chaincodeID, err)
913+
theChaincodeSupport.Stop(ctxt, cccid, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec})
914+
return
915+
}
916+
917+
f = "put"
918+
args = util.ToChaincodeArgs(f, "key3", "{\"shipmentID\":\"161003PKC7300\",\"customsInvoice\":{\"methodOfTransport\":\"GROUND\",\"invoiceNumber\":\"00091622\"},\"weightUnitOfMeasure\":\"KGM\",\"volumeUnitOfMeasure\": \"CO\",\"dimensionUnitOfMeasure\":\"CM\",\"currency\":\"USD\"}")
919+
spec = &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID, Input: &pb.ChaincodeInput{Args: args}}
920+
_, _, _, err = invoke(ctxt, chainID, spec)
921+
922+
if err != nil {
923+
t.Fail()
924+
t.Logf("Error invoking <%s>: %s", chaincodeID, err)
925+
theChaincodeSupport.Stop(ctxt, cccid, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec})
926+
return
927+
}
928+
894929
f = "keys"
895-
args = util.ToChaincodeArgs(f)
930+
args = util.ToChaincodeArgs(f, "key0", "key3")
896931

897932
spec = &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID, Input: &pb.ChaincodeInput{Args: args}}
898933
_, _, _, err = invoke(ctxt, chainID, spec)
@@ -903,6 +938,21 @@ func TestRangeQuery(t *testing.T) {
903938
theChaincodeSupport.Stop(ctxt, cccid, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec})
904939
return
905940
}
941+
942+
if ledgerconfig.IsCouchDBEnabled() == true {
943+
f = "query"
944+
args = util.ToChaincodeArgs(f, "{\"selector\":{\"currency\":\"USD\"}}")
945+
946+
spec = &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID, Input: &pb.ChaincodeInput{Args: args}}
947+
_, _, _, err = invoke(ctxt, chainID, spec)
948+
949+
if err != nil {
950+
t.Fail()
951+
t.Logf("Error invoking <%s>: %s", chaincodeID, err)
952+
theChaincodeSupport.Stop(ctxt, cccid, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec})
953+
return
954+
}
955+
}
906956
theChaincodeSupport.Stop(ctxt, cccid, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec})
907957
}
908958

core/chaincode/handler.go

+165-54
Large diffs are not rendered by default.

core/chaincode/shim/chaincode.go

+21-12
Original file line numberDiff line numberDiff line change
@@ -315,12 +315,12 @@ func (stub *ChaincodeStub) DelState(key string) error {
315315
return stub.handler.handleDelState(key, stub.TxID)
316316
}
317317

318-
// StateRangeQueryIterator allows a chaincode to iterate over a range of
318+
// StateQueryIterator allows a chaincode to iterate over a set of
319319
// key/value pairs in the state.
320-
type StateRangeQueryIterator struct {
320+
type StateQueryIterator struct {
321321
handler *Handler
322322
uuid string
323-
response *pb.RangeQueryStateResponse
323+
response *pb.QueryStateResponse
324324
currentLoc int
325325
}
326326

@@ -329,12 +329,21 @@ type StateRangeQueryIterator struct {
329329
// an iterator will be returned that can be used to iterate over all keys
330330
// between the startKey and endKey, inclusive. The order in which keys are
331331
// returned by the iterator is random.
332-
func (stub *ChaincodeStub) RangeQueryState(startKey, endKey string) (StateRangeQueryIteratorInterface, error) {
332+
func (stub *ChaincodeStub) RangeQueryState(startKey, endKey string) (StateQueryIteratorInterface, error) {
333333
response, err := stub.handler.handleRangeQueryState(startKey, endKey, stub.TxID)
334334
if err != nil {
335335
return nil, err
336336
}
337-
return &StateRangeQueryIterator{stub.handler, stub.TxID, response, 0}, nil
337+
return &StateQueryIterator{stub.handler, stub.TxID, response, 0}, nil
338+
}
339+
340+
func (stub *ChaincodeStub) ExecuteQuery(query string) (StateQueryIteratorInterface, error) {
341+
response, err := stub.handler.handleExecuteQueryState(query, stub.TxID)
342+
if err != nil {
343+
return nil, err
344+
}
345+
return &StateQueryIterator{stub.handler, stub.TxID, response, 0}, nil
346+
338347
}
339348

340349
//Given a list of attributes, createCompositeKey function combines these attributes
@@ -359,11 +368,11 @@ func createCompositeKey(stub ChaincodeStubInterface, objectType string, attribut
359368
//matches the given partial composite key. This function should be used only for
360369
//a partial composite key. For a full composite key, an iter with empty response
361370
//would be returned.
362-
func (stub *ChaincodeStub) PartialCompositeKeyQuery(objectType string, attributes []string) (StateRangeQueryIteratorInterface, error) {
371+
func (stub *ChaincodeStub) PartialCompositeKeyQuery(objectType string, attributes []string) (StateQueryIteratorInterface, error) {
363372
return partialCompositeKeyQuery(stub, objectType, attributes)
364373
}
365374

366-
func partialCompositeKeyQuery(stub ChaincodeStubInterface, objectType string, attributes []string) (StateRangeQueryIteratorInterface, error) {
375+
func partialCompositeKeyQuery(stub ChaincodeStubInterface, objectType string, attributes []string) (StateQueryIteratorInterface, error) {
367376
partialCompositeKey, _ := stub.CreateCompositeKey(objectType, attributes)
368377
keysIter, err := stub.RangeQueryState(partialCompositeKey+"1", partialCompositeKey+":")
369378
if err != nil {
@@ -374,23 +383,23 @@ func partialCompositeKeyQuery(stub ChaincodeStubInterface, objectType string, at
374383

375384
// HasNext returns true if the range query iterator contains additional keys
376385
// and values.
377-
func (iter *StateRangeQueryIterator) HasNext() bool {
386+
func (iter *StateQueryIterator) HasNext() bool {
378387
if iter.currentLoc < len(iter.response.KeysAndValues) || iter.response.HasMore {
379388
return true
380389
}
381390
return false
382391
}
383392

384393
// Next returns the next key and value in the range query iterator.
385-
func (iter *StateRangeQueryIterator) Next() (string, []byte, error) {
394+
func (iter *StateQueryIterator) Next() (string, []byte, error) {
386395
if iter.currentLoc < len(iter.response.KeysAndValues) {
387396
keyValue := iter.response.KeysAndValues[iter.currentLoc]
388397
iter.currentLoc++
389398
return keyValue.Key, keyValue.Value, nil
390399
} else if !iter.response.HasMore {
391400
return "", nil, errors.New("No such key")
392401
} else {
393-
response, err := iter.handler.handleRangeQueryStateNext(iter.response.ID, iter.uuid)
402+
response, err := iter.handler.handleQueryStateNext(iter.response.ID, iter.uuid)
394403

395404
if err != nil {
396405
return "", nil, err
@@ -407,8 +416,8 @@ func (iter *StateRangeQueryIterator) Next() (string, []byte, error) {
407416

408417
// Close closes the range query iterator. This should be called when done
409418
// reading from the iterator to free up resources.
410-
func (iter *StateRangeQueryIterator) Close() error {
411-
_, err := iter.handler.handleRangeQueryStateClose(iter.response.ID, iter.uuid)
419+
func (iter *StateQueryIterator) Close() error {
420+
_, err := iter.handler.handleQueryStateClose(iter.response.ID, iter.uuid)
412421
return err
413422
}
414423

core/chaincode/shim/handler.go

+66-18
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ func (handler *Handler) handleDelState(key string, txid string) error {
494494
return errors.New("Incorrect chaincode message received")
495495
}
496496

497-
func (handler *Handler) handleRangeQueryState(startKey, endKey string, txid string) (*pb.RangeQueryStateResponse, error) {
497+
func (handler *Handler) handleRangeQueryState(startKey, endKey string, txid string) (*pb.QueryStateResponse, error) {
498498
// Create the channel on which to communicate the response from validating peer
499499
respChan, uniqueReqErr := handler.createChannel(txid)
500500
if uniqueReqErr != nil {
@@ -522,7 +522,7 @@ func (handler *Handler) handleRangeQueryState(startKey, endKey string, txid stri
522522
// Success response
523523
chaincodeLogger.Debugf("[%s]Received %s. Successfully got range", shorttxid(responseMsg.Txid), pb.ChaincodeMessage_RESPONSE)
524524

525-
rangeQueryResponse := &pb.RangeQueryStateResponse{}
525+
rangeQueryResponse := &pb.QueryStateResponse{}
526526
unmarshalErr := proto.Unmarshal(responseMsg.Payload, rangeQueryResponse)
527527
if unmarshalErr != nil {
528528
chaincodeLogger.Errorf("[%s]unmarshall error", shorttxid(responseMsg.Txid))
@@ -542,7 +542,7 @@ func (handler *Handler) handleRangeQueryState(startKey, endKey string, txid stri
542542
return nil, errors.New("Incorrect chaincode message received")
543543
}
544544

545-
func (handler *Handler) handleRangeQueryStateNext(id, txid string) (*pb.RangeQueryStateResponse, error) {
545+
func (handler *Handler) handleQueryStateNext(id, txid string) (*pb.QueryStateResponse, error) {
546546
// Create the channel on which to communicate the response from validating peer
547547
respChan, uniqueReqErr := handler.createChannel(txid)
548548
if uniqueReqErr != nil {
@@ -553,31 +553,31 @@ func (handler *Handler) handleRangeQueryStateNext(id, txid string) (*pb.RangeQue
553553
defer handler.deleteChannel(txid)
554554

555555
// Send RANGE_QUERY_STATE_NEXT message to validator chaincode support
556-
payload := &pb.RangeQueryStateNext{ID: id}
556+
payload := &pb.QueryStateNext{ID: id}
557557
payloadBytes, err := proto.Marshal(payload)
558558
if err != nil {
559559
return nil, errors.New("Failed to process range query state next request")
560560
}
561-
msg := &pb.ChaincodeMessage{Type: pb.ChaincodeMessage_RANGE_QUERY_STATE_NEXT, Payload: payloadBytes, Txid: txid}
562-
chaincodeLogger.Debugf("[%s]Sending %s", shorttxid(msg.Txid), pb.ChaincodeMessage_RANGE_QUERY_STATE_NEXT)
561+
msg := &pb.ChaincodeMessage{Type: pb.ChaincodeMessage_QUERY_STATE_NEXT, Payload: payloadBytes, Txid: txid}
562+
chaincodeLogger.Debugf("[%s]Sending %s", shorttxid(msg.Txid), pb.ChaincodeMessage_QUERY_STATE_NEXT)
563563
responseMsg, err := handler.sendReceive(msg, respChan)
564564
if err != nil {
565-
chaincodeLogger.Errorf("[%s]error sending %s", shorttxid(msg.Txid), pb.ChaincodeMessage_RANGE_QUERY_STATE_NEXT)
565+
chaincodeLogger.Errorf("[%s]error sending %s", shorttxid(msg.Txid), pb.ChaincodeMessage_QUERY_STATE_NEXT)
566566
return nil, errors.New("could not send msg")
567567
}
568568

569569
if responseMsg.Type.String() == pb.ChaincodeMessage_RESPONSE.String() {
570570
// Success response
571571
chaincodeLogger.Debugf("[%s]Received %s. Successfully got range", shorttxid(responseMsg.Txid), pb.ChaincodeMessage_RESPONSE)
572572

573-
rangeQueryResponse := &pb.RangeQueryStateResponse{}
574-
unmarshalErr := proto.Unmarshal(responseMsg.Payload, rangeQueryResponse)
573+
queryResponse := &pb.QueryStateResponse{}
574+
unmarshalErr := proto.Unmarshal(responseMsg.Payload, queryResponse)
575575
if unmarshalErr != nil {
576576
chaincodeLogger.Errorf("[%s]unmarshall error", shorttxid(responseMsg.Txid))
577577
return nil, errors.New("Error unmarshalling RangeQueryStateResponse.")
578578
}
579579

580-
return rangeQueryResponse, nil
580+
return queryResponse, nil
581581
}
582582
if responseMsg.Type.String() == pb.ChaincodeMessage_ERROR.String() {
583583
// Error response
@@ -590,7 +590,7 @@ func (handler *Handler) handleRangeQueryStateNext(id, txid string) (*pb.RangeQue
590590
return nil, errors.New("Incorrect chaincode message received")
591591
}
592592

593-
func (handler *Handler) handleRangeQueryStateClose(id, txid string) (*pb.RangeQueryStateResponse, error) {
593+
func (handler *Handler) handleQueryStateClose(id, txid string) (*pb.QueryStateResponse, error) {
594594
// Create the channel on which to communicate the response from validating peer
595595
respChan, uniqueReqErr := handler.createChannel(txid)
596596
if uniqueReqErr != nil {
@@ -601,31 +601,79 @@ func (handler *Handler) handleRangeQueryStateClose(id, txid string) (*pb.RangeQu
601601
defer handler.deleteChannel(txid)
602602

603603
// Send RANGE_QUERY_STATE_CLOSE message to validator chaincode support
604-
payload := &pb.RangeQueryStateClose{ID: id}
604+
payload := &pb.QueryStateClose{ID: id}
605605
payloadBytes, err := proto.Marshal(payload)
606606
if err != nil {
607607
return nil, errors.New("Failed to process range query state close request")
608608
}
609-
msg := &pb.ChaincodeMessage{Type: pb.ChaincodeMessage_RANGE_QUERY_STATE_CLOSE, Payload: payloadBytes, Txid: txid}
610-
chaincodeLogger.Debugf("[%s]Sending %s", shorttxid(msg.Txid), pb.ChaincodeMessage_RANGE_QUERY_STATE_CLOSE)
609+
msg := &pb.ChaincodeMessage{Type: pb.ChaincodeMessage_QUERY_STATE_CLOSE, Payload: payloadBytes, Txid: txid}
610+
chaincodeLogger.Debugf("[%s]Sending %s", shorttxid(msg.Txid), pb.ChaincodeMessage_QUERY_STATE_CLOSE)
611611
responseMsg, err := handler.sendReceive(msg, respChan)
612612
if err != nil {
613-
chaincodeLogger.Errorf("[%s]error sending %s", shorttxid(msg.Txid), pb.ChaincodeMessage_RANGE_QUERY_STATE_CLOSE)
613+
chaincodeLogger.Errorf("[%s]error sending %s", shorttxid(msg.Txid), pb.ChaincodeMessage_QUERY_STATE_CLOSE)
614614
return nil, errors.New("could not send msg")
615615
}
616616

617617
if responseMsg.Type.String() == pb.ChaincodeMessage_RESPONSE.String() {
618618
// Success response
619619
chaincodeLogger.Debugf("[%s]Received %s. Successfully got range", shorttxid(responseMsg.Txid), pb.ChaincodeMessage_RESPONSE)
620620

621-
rangeQueryResponse := &pb.RangeQueryStateResponse{}
622-
unmarshalErr := proto.Unmarshal(responseMsg.Payload, rangeQueryResponse)
621+
queryResponse := &pb.QueryStateResponse{}
622+
unmarshalErr := proto.Unmarshal(responseMsg.Payload, queryResponse)
623623
if unmarshalErr != nil {
624624
chaincodeLogger.Errorf("[%s]unmarshall error", shorttxid(responseMsg.Txid))
625625
return nil, errors.New("Error unmarshalling RangeQueryStateResponse.")
626626
}
627627

628-
return rangeQueryResponse, nil
628+
return queryResponse, nil
629+
}
630+
if responseMsg.Type.String() == pb.ChaincodeMessage_ERROR.String() {
631+
// Error response
632+
chaincodeLogger.Errorf("[%s]Received %s", shorttxid(responseMsg.Txid), pb.ChaincodeMessage_ERROR)
633+
return nil, errors.New(string(responseMsg.Payload[:]))
634+
}
635+
636+
// Incorrect chaincode message received
637+
chaincodeLogger.Errorf("Incorrect chaincode message %s recieved. Expecting %s or %s", responseMsg.Type, pb.ChaincodeMessage_RESPONSE, pb.ChaincodeMessage_ERROR)
638+
return nil, errors.New("Incorrect chaincode message received")
639+
}
640+
641+
func (handler *Handler) handleExecuteQueryState(query string, txid string) (*pb.QueryStateResponse, error) {
642+
// Create the channel on which to communicate the response from validating peer
643+
respChan, uniqueReqErr := handler.createChannel(txid)
644+
if uniqueReqErr != nil {
645+
chaincodeLogger.Debugf("[%s]Another state request pending for this Txid. Cannot process.", shorttxid(txid))
646+
return nil, uniqueReqErr
647+
}
648+
649+
defer handler.deleteChannel(txid)
650+
651+
// Send EXECUTE_QUERY_STATE message to validator chaincode support
652+
payload := &pb.ExecuteQueryState{Query: query}
653+
payloadBytes, err := proto.Marshal(payload)
654+
if err != nil {
655+
return nil, errors.New("Failed to process range query state request")
656+
}
657+
msg := &pb.ChaincodeMessage{Type: pb.ChaincodeMessage_EXECUTE_QUERY_STATE, Payload: payloadBytes, Txid: txid}
658+
chaincodeLogger.Debugf("[%s]Sending %s", shorttxid(msg.Txid), pb.ChaincodeMessage_EXECUTE_QUERY_STATE)
659+
responseMsg, err := handler.sendReceive(msg, respChan)
660+
if err != nil {
661+
chaincodeLogger.Errorf("[%s]error sending %s", shorttxid(msg.Txid), pb.ChaincodeMessage_EXECUTE_QUERY_STATE)
662+
return nil, errors.New("could not send msg")
663+
}
664+
665+
if responseMsg.Type.String() == pb.ChaincodeMessage_RESPONSE.String() {
666+
// Success response
667+
chaincodeLogger.Debugf("[%s]Received %s. Successfully got range", shorttxid(responseMsg.Txid), pb.ChaincodeMessage_RESPONSE)
668+
669+
executeQueryResponse := &pb.QueryStateResponse{}
670+
unmarshalErr := proto.Unmarshal(responseMsg.Payload, executeQueryResponse)
671+
if unmarshalErr != nil {
672+
chaincodeLogger.Errorf("[%s]unmarshall error", shorttxid(responseMsg.Txid))
673+
return nil, errors.New("Error unmarshalling QueryStateResponse.")
674+
}
675+
676+
return executeQueryResponse, nil
629677
}
630678
if responseMsg.Type.String() == pb.ChaincodeMessage_ERROR.String() {
631679
// Error response

core/chaincode/shim/interfaces.go

+6-4
Original file line numberDiff line numberDiff line change
@@ -68,20 +68,22 @@ type ChaincodeStubInterface interface {
6868
// an iterator will be returned that can be used to iterate over all keys
6969
// between the startKey and endKey, inclusive. The order in which keys are
7070
// returned by the iterator is random.
71-
RangeQueryState(startKey, endKey string) (StateRangeQueryIteratorInterface, error)
71+
RangeQueryState(startKey, endKey string) (StateQueryIteratorInterface, error)
7272

7373
//PartialCompositeKeyQuery function can be invoked by a chaincode to query the
7474
//state based on a given partial composite key. This function returns an
7575
//iterator which can be used to iterate over all composite keys whose prefix
7676
//matches the given partial composite key. This function should be used only for
7777
//a partial composite key. For a full composite key, an iter with empty response
7878
//would be returned.
79-
PartialCompositeKeyQuery(objectType string, keys []string) (StateRangeQueryIteratorInterface, error)
79+
PartialCompositeKeyQuery(objectType string, keys []string) (StateQueryIteratorInterface, error)
8080

8181
//Given a list of attributes, createCompundKey function combines these attributes
8282
//to form a composite key.
8383
CreateCompositeKey(objectType string, attributes []string) (string, error)
8484

85+
ExecuteQuery(query string) (StateQueryIteratorInterface, error)
86+
8587
// GetCallerCertificate returns caller certificate
8688
GetCallerCertificate() ([]byte, error)
8789

@@ -104,9 +106,9 @@ type ChaincodeStubInterface interface {
104106
SetEvent(name string, payload []byte) error
105107
}
106108

107-
// StateRangeQueryIteratorInterface allows a chaincode to iterate over a range of
109+
// StateQueryIteratorInterface allows a chaincode to iterate over a set of
108110
// key/value pairs in the state.
109-
type StateRangeQueryIteratorInterface interface {
111+
type StateQueryIteratorInterface interface {
110112

111113
// HasNext returns true if the range query iterator contains additional keys
112114
// and values.

core/chaincode/shim/java/src/main/java/org/hyperledger/java/shim/ChaincodeStub.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public Map<String, String> rangeQueryState(String startKey, String endKey) {
102102
*/
103103
public Map<String, ByteString> rangeQueryRawState(String startKey, String endKey) {
104104
Map<String, ByteString> map = new HashMap<>();
105-
for (Chaincode.RangeQueryStateKeyValue mapping : handler.handleRangeQueryState(
105+
for (Chaincode.QueryStateKeyValue mapping : handler.handleRangeQueryState(
106106
startKey, endKey, uuid).getKeysAndValuesList()) {
107107
map.put(mapping.getKey(), mapping.getValue());
108108
}

0 commit comments

Comments
 (0)