Hyperledger Composer问题身份但名片缺失 [英] Hyperledger Composer issue identity but missing business card

查看:79
本文介绍了Hyperledger Composer问题身份但名片缺失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Node.js应用程序和"composer-client" npm模块进行概念验证.

I am working in a proof of concept with a Node.js application and 'composer-client' npm module.

我尝试了不同的命令,例如添加参与者,添加资产和执行交易,一切似乎都能正常工作.

I have tried different commands such as adding a participant, adding an asset and performing a transaction and everything seems to work correctly.

但是,当我尝试发布新的身份时,我没有得到预期的结果.我使用以下代码执行Node.js应用程序:

However, when I try to issue a new identity I do not get the results that I expect. I execute my Node.js application with the following code:

var businessNetwork = new BusinessNetworkConnection();
return businessNetwork.connect('admin@tutorial-network')
.then(() => {
  return businessNetwork.issueIdentity('org.acme.biznet.Trader#Trader_001', 'usr001')
})
.then((result) => {
  console.log(`userID = ${result.userID}`);
  console.log(`userSecret = ${result.userSecret}`);
})
.catch((error) => {
  console.error(error);
});

然后,在控制台日志中显示UserId和UserSecret.之后,我尝试对企业网络执行ping操作:

Then, UserId and UserSecret are displayed at console log. After that, I try to do a ping to Business Network:

var businessNetwork = new BusinessNetworkConnection();
return businessNetwork.connect('usr001@tutorial-network')
.then(() => {
  return businessNetwork.ping();
})
.then((result) => {
  console.log(`participant = ${result.participant ? result.participant : '<no participant found>'}`);
})
.catch((error) => {
  console.error(error);
});

但是,我收到以下错误消息:

However, I get the following error message:

{ Error: Card not found: usr001@tutorial-network
at IdCard.fromDirectory.catch.cause (/home/user.name/git_repositories/nodejs/first.blockchain.test/node_modules/composer-common/lib/cardstore/filesystemcardstore.js:73:27)
at <anonymous>
cause: 
{ Error: Unable to read card directory: /home/user.name/.composer/cards/user001@tutorial-network

如果执行命令composer identity list -c admin@tutorial-network,则会得到以下输出:

If I execute the command composer identity list -c admin@tutorial-network, I get the following output:

$class:      org.hyperledger.composer.system.Identity
  identityId:  9b49f67c262c0ae23e1e0c4a8dc61c4a12b5119df2b6a49fa2e02fa56b8818c3
  name:        usr001
  issuer:      27c582d674ddf0f230854814b7cfd04553f3d0eac55e37d915386c614a5a1de9
  certificate: 
  state:       ISSUED
  participant: resource:org.acme.biznet.Trader#Trader_001

但是,我找不到名片.

推荐答案

我使用以下命令,使用从javascript获取的注册机密为参与者创建了一张卡片.

I used the following command to create a card for the participant using the enrollment secret obtained from the javascript.

composer card create -u usr001 -s <enrollment_secret> -f usr001.card -n tutorial-network -p connection.json

您可能已在遵循本教程之前的某个步骤中创建了connection.json.如果此文件不是明确可用的,则可以从作曲家的钱包中获取.在当前版本中,它可以位于/home/your_user/.composer/cards/中.如果您仅遵循本教程,则此目录中的所有connection.json都可以. 之后,您必须使用以下方法将创建的凭证添加到钱包中:

You probably created the connection.json needed in some step before in the tutorial you are following. If this file is not available explicitly, you may get it from the composer wallet. In the current version, it can be located in /home/your_user/.composer/cards/. If you are only following the tutorial, any connection.json in this directory will do. After that, you must add the credential created to the wallet using:

composer card import -f usr001.card

您用于验证所发布身份的代码正确无误.

Your code for testing the issued identity is correct.

这篇关于Hyperledger Composer问题身份但名片缺失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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