2

我已经从 fabric-samples 实例化了一个示例 NodeJS 链代码,marbles02所有调用和查询函数都工作正常,但是当我试图查询这个函数queryMarblesWithPagination时,它给了我这个错误:

Error: endorsement failure during query. response: status:500 message:"transaction returned with failure: TypeError: stub.GetQueryResultWithPagination is not a function"

我的链码日志是:

Args: ["queryMarblesWithPagination","{\"selector\":{\"owner\":\"tom\"}}","3",""]
{ fcn: 'queryMarblesWithPagination',
  params: [ '{"selector":{"owner":"tom"}}', '3', '' ] }
TypeError: stub.GetQueryResultWithPagination is not a function
    at queryMarblesWithPagination (/usr/local/src/marbles_chaincode.js:468:47)
    at Chaincode.Invoke (/usr/local/src/marbles_chaincode.js:55:27)
    at handleMessage (/usr/local/src/node_modules/fabric-shim/lib/handler.js:636:47)
    at ChaincodeSupportClient.handleTransaction (/usr/local/src/node_modules/fabric-shim/lib/handler.js:361:9)
    at ClientDuplexStream.<anonymous> (/usr/local/src/node_modules/fabric-shim/lib/handler.js:301:30)
    at emitOne (events.js:116:13)
    at ClientDuplexStream.emit (events.js:211:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:250:11)
    at ClientDuplexStream.Readable.push (_stream_readable.js:208:10)
2019-08-29T08:01:17.786Z error [shim:lib/handler.js]                              [mychannel-d8dd2e62] Calling chaincode Invoke() returned error response [TypeError: stub.GetQueryResultWithPagination is not a function]. Sending ERROR message back to peer  
4

3 回答 3

1

我认为示例中有一个“错字”-函数名称应以小写g开头-getQueryResultWithPagination

于 2019-08-29T09:10:49.140 回答
1

我在 stub.js 中看到的是函数名称以小 g 开头而不是大写 G。因此,stub.GetQueryResultWithPagination您应该尝试而不是调用stub.getQueryResultWithPagination。这应该可以解决您的错误。

于 2019-08-29T09:12:54.833 回答
1

人们已经回答了,但我认为下面的链接将来可能会对您有所帮助

hyperledger fabric shim 有一个 golang 接口,你可以找到所有可用的方法

https://github.com/hyperledger/fabric/blob/master/core/chaincode/shim/interfaces.go

于 2019-08-29T09:50:49.463 回答