Correct index location (#443)

Signed-off-by: Matthew B White <whitemat@uk.ibm.com>
This commit is contained in:
Matthew B White 2021-04-29 10:21:41 +01:00 committed by GitHub
parent 9db8164f04
commit ce5186008b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 6 deletions

View file

@ -181,7 +181,7 @@ class Chaincode extends Contract {
async GetAssetsByRange(ctx, startKey, endKey) {
let resultsIterator = await ctx.stub.getStateByRange(startKey, endKey);
let results = await this.GetAllResults(resultsIterator, false);
let results = await this._GetAllResults(resultsIterator, false);
return JSON.stringify(results);
}
@ -249,7 +249,7 @@ class Chaincode extends Contract {
async GetQueryResultForQueryString(ctx, queryString) {
let resultsIterator = await ctx.stub.getQueryResult(queryString);
let results = await this.GetAllResults(resultsIterator, false);
let results = await this._GetAllResults(resultsIterator, false);
return JSON.stringify(results);
}
@ -262,7 +262,7 @@ class Chaincode extends Contract {
async GetAssetsByRangeWithPagination(ctx, startKey, endKey, pageSize, bookmark) {
const {iterator, metadata} = await ctx.stub.getStateByRangeWithPagination(startKey, endKey, pageSize, bookmark);
const results = await this.GetAllResults(iterator, false);
const results = await this._GetAllResults(iterator, false);
results.ResponseMetadata = {
RecordsCount: metadata.fetched_records_count,
@ -282,7 +282,7 @@ class Chaincode extends Contract {
async QueryAssetsWithPagination(ctx, queryString, pageSize, bookmark) {
const {iterator, metadata} = await ctx.stub.getQueryResultWithPagination(queryString, pageSize, bookmark);
const results = await this.GetAllResults(iterator, false);
const results = await this._GetAllResults(iterator, false);
results.ResponseMetadata = {
RecordsCount: metadata.fetched_records_count,
@ -296,7 +296,7 @@ class Chaincode extends Contract {
async GetAssetHistory(ctx, assetName) {
let resultsIterator = await ctx.stub.getHistoryForKey(assetName);
let results = await this.GetAllResults(resultsIterator, true);
let results = await this._GetAllResults(resultsIterator, true);
return JSON.stringify(results);
}
@ -308,7 +308,11 @@ class Chaincode extends Contract {
return assetState && assetState.length > 0;
}
async GetAllResults(iterator, isHistory) {
// This is JavaScript so without Funcation Decorators, all functions are assumed
// to be transaction functions
//
// For internal functions... prefix them with _
async _GetAllResults(iterator, isHistory) {
let allResults = [];
let res = await iterator.next();
while (!res.done) {