如何调试chaincode? LedgerError-ResourceNotFound [英] How to debug chaincode? LedgerError - ResourceNotFound

查看:157
本文介绍了如何调试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.

此处

首先,仅将链代码部署事务发送一次到 验证对等体. CLI使用以下命令连接到验证对等方: 在core.yaml文件中定义的属性.注意:部署事务 通常需要一个path参数来定位,构建和部署 链码.但是,由于这些说明是特定于本地的 开发模式和链码是手动部署的,名称 参数代替.

First, send a chaincode deploy transaction, only once, to the validating peer. The CLI connects to the validating peer using the properties defined in the core.yaml file. Note: The deploy transaction typically requires a path parameter to locate, build, and deploy the chaincode. However, because these instructions are specific to local development mode and the chaincode is deployed manually, the name parameter is used instead.

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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆