本文介绍了如何调试chaincode? LedgerError-ResourceNotFound的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我明白了,我相信这是很常见的错误"..LedgerError - ResourceNotFound: ledger: resource not found" .

I got this I believe pretty common error "..LedgerError - ResourceNotFound: ledger: resource not found" .

为简单起见,这就是我所拥有的:

To make it simple, this is what I have:

  1. 尝试简单的链式代码,使用给定的chaincode_example02.go代码

关闭了安全性,因此没有CA (CORE_SECURITY_ENABLED=false CORE_SECURITY_PRIVACY=falss)

turned off security hence no CA (CORE_SECURITY_ENABLED=false CORE_SECURITY_PRIVACY=falss)

仅1个对等节点(使用0.5版本),它是对等docker映像

1 peer node only (using 0.5 version), it is a peer docker image

以开发人员模式运行

这是我在开发模式下部署代码的方式,请验证cli是否正确:

This is how I deployed the code in dev mode, pls do verify if the cli is correct:

CORE_CHAINCODE_ID_NAME=mycc CORE_PEER_ADDRESS=0.0.0.0:30303 ./chaincode_example02 

它显示

'Received REGISTERED, ready for invocations'

现在尝试查询它,请确认此cli是否正确:

Now trying to query it, pls do verify if this cli is correct :

peer chaincode query -n mycc -c '{"Function": "query", "Args": ["b"]}'

但返回的错误是:

Error: Error querying chaincode: rpc error: code = 2 desc = "Error:Failed to launch chaincode spec(Could not get deployment transaction for chaincode_example02 - LedgerError - ResourceNotFound: ledger: resource not found)"

有什么主意吗?我检查了/var下的所有日志,但没有找到有用的东西,还检查了/var/hyperledger,并确实看到了/var/hyperledger/production/db下的某些更新.

Any idea? I checked all logs under /var but didn't find anything useful, also checked /var/hyperledger and did see some updates under /var/hyperledger/production/db.

该审判似乎很简单,但是却意外地出错.

This trial seems pretty straight forwards but surprise to get an error.

..那么我应该如何调试呢?

.. so how should I go about debugging this?

推荐答案

以下命令,

CORE_CHAINCODE_ID_NAME=mycc CORE_PEER_ADDRESS=0.0.0.0:30303 ./chaincode_example02 

不是deploy链码,它只是启动链码并将其注册到验证对等方.

doesn't deploy the chaincode, it simply start and register the chaincode with the validating peer.

注册后,需要先deploy然后invoke它,然后才能query.

Once it is registered, you need todeploy and then invoke it before you can query.

此处

peer chaincode deploy -n mycc -c '{"Function":"init", "Args": ["a","100", "b", "200"]}'

一旦部署,您可以根据需要多次调用它,然后query调用的事务,

Once it is deployed, you can invoke it as many times you want and then query the invoked transaction,

invoke

peer chaincode invoke -l golang -n mycc -c '{"Function": "invoke", "Args": ["a", "b", "10"]}'

query

peer chaincode query -l golang -n mycc -c '{"Function": "query", "Args": ["b"]}'

还要确保在一个终端中运行peer,在第二个终端中运行链码,同时从第三个终端部署,调用和查询事务.

Also make sure that you have peer running in one terminal, running the chaincode in 2nd terminal, while deploying, invoking and querying transactions from the third one.

这篇关于如何调试chaincode? LedgerError-ResourceNotFound的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-13 23:47