Skip to content

Commit bcbc8f9

Browse files
committed
- parse query correctly
1 parent 2d93c3a commit bcbc8f9

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

index.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ ibc.prototype.load_chaincode = function(options, cb) {
288288
var regex = /function\s+==\s+["'](\w+)["']/g; //find the exposed chaincode functions in "Run()""
289289
var result2;
290290
while ( (result2 = regex.exec(str)) ) {
291-
cc_suspects.push(result2[1]); //store this for when parsing query which runs next
291+
cc_suspects.push({name: result2[1], index: result2.index}); //store this for when parsing query which runs next
292292
if(result2.index > i_start && result2.index < i_stop){ //make sure its inside Run()
293293
cc_invocations.push(result2[1]);
294294
}
@@ -328,7 +328,7 @@ ibc.prototype.load_chaincode = function(options, cb) {
328328
// Step 2b.
329329
for(i in cc_suspects){
330330
if(cc_suspects[i].index > q_start && cc_suspects[i].index < q_stop){//make sure its inside Query()
331-
cc_queries.push(cc_suspects[i][1]);
331+
cc_queries.push(cc_suspects[i].name);
332332
}
333333
}
334334

@@ -806,7 +806,7 @@ function build_invoke_func(name){
806806
//build_query_func() - create JS function that calls the custom goLang function in the chaincode
807807
//==================================================================
808808
function build_query_func(name){
809-
if(ibc.chaincode.query[name] != null){ //skip if already exists
809+
if(ibc.chaincode.query[name] != null && name !== 'read'){ //skip if already exists
810810
//console.log('[ibc-js] \t skip, func', name, 'already exists');
811811
}
812812
else {
@@ -838,8 +838,7 @@ function build_query_func(name){
838838

839839
options.success = function(statusCode, data){
840840
console.log('[ibc-js]', name, ' - success:', data);
841-
ibc.q.push(Date.now()); //new action, add it to queue
842-
if(cb) cb(null, data);
841+
if(cb) cb(null, data.OK);
843842
};
844843
options.failure = function(statusCode, e){
845844
console.log('[ibc-js]', name, ' - failure:', statusCode, e);

0 commit comments

Comments
 (0)