Skip to content

Commit

Permalink
mv rangequery option validation to ledger/internal
Browse files Browse the repository at this point in the history
The range query receives metadata such as pagination limit.
ValidateRangeMetadata() validates the received metadata. As
the ValidateRangeMetadata() is present in statedb, it is imported
in both statecouchdb and stateleveldb packages. As we want these
packages to be self-sufficient and only import ledger/internal
packages, we move the ValidateRangeMetadata() to
ledger/interal/rangequery.

Further, the term metadata is confusing with the statemetadata
which stores the key-based endorsement. Hence, we replace
Metadata in range query API with options.

Signed-off-by: senthil <cendhu@gmail.com>
  • Loading branch information
cendhu committed Apr 8, 2020
1 parent a6beb4e commit d347d13
Show file tree
Hide file tree
Showing 25 changed files with 495 additions and 481 deletions.
2 changes: 1 addition & 1 deletion core/chaincode/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ func (h *Handler) HandleGetStateByRange(msg *pb.ChaincodeMessage, txContext *Tra
startKey = metadata.Bookmark
}
}
rangeIter, err = txContext.TXSimulator.GetStateRangeScanIteratorWithMetadata(namespaceID,
rangeIter, err = txContext.TXSimulator.GetStateRangeScanIteratorWithOptions(namespaceID,
startKey, getStateByRange.EndKey, paginationInfo)
} else {
rangeIter, err = txContext.TXSimulator.GetStateRangeScanIterator(namespaceID, getStateByRange.StartKey, getStateByRange.EndKey)
Expand Down
80 changes: 40 additions & 40 deletions core/chaincode/mock/tx_simulator.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 8 additions & 11 deletions core/committer/txvalidator/mocks/query_executor.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions core/committer/txvalidator/v14/validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1552,8 +1552,8 @@ func (exec *mockQueryExecutor) GetStateRangeScanIterator(namespace string, start
return args.Get(0).(ledger2.ResultsIterator), args.Error(1)
}

func (exec *mockQueryExecutor) GetStateRangeScanIteratorWithMetadata(namespace, startKey, endKey string, metadata map[string]interface{}) (ledger.QueryResultsIterator, error) {
args := exec.Called(namespace, startKey, endKey, metadata)
func (exec *mockQueryExecutor) GetStateRangeScanIteratorWithOptions(namespace, startKey, endKey string, options map[string]interface{}) (ledger.QueryResultsIterator, error) {
args := exec.Called(namespace, startKey, endKey, options)
return args.Get(0).(ledger.QueryResultsIterator), args.Error(1)
}

Expand Down
19 changes: 8 additions & 11 deletions core/committer/txvalidator/v20/mocks/query_executor.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d347d13

Please sign in to comment.