首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ChainCode容器生命周期说明

ChainCode容器生命周期说明
EN

Stack Overflow用户
提问于 2019-03-09 01:51:51
回答 1查看 123关注 0票数 0

所以我想知道我的设置是否有一些缺陷,或者我没有理解链码容器生命周期的概念。

问题如下。在通道上安装/实例化链代码后,我必须通过docker cli对链代码进行查询/调用,然后才能从nodejs后端对相应的注册对等体执行相同的操作。

因此,当查看docker日志时,直到我从docker cli发出调用,链码容器才处于活动状态。这是故意的吗?或者是遗漏了什么设置?如果能为我澄清这个问题或发布一些文档,那将是非常酷的。

EN

回答 1

Stack Overflow用户

发布于 2019-03-09 14:21:59

这是正常的,发生这种情况的原因是因为实例化时的fabric只在实例化它的对等点上旋转链代码的docker容器。因此,当您尝试通过其他对等节点调用或查询链码时,它需要首先启动容器,然后才会执行查询。

另一种方法是通过通道中的所有背书对等体实例化链代码,因为targets.This确保在调用或查询之前通道中的所有对等体都具有容器。

如果您使用的是go-sdk,这是通过withTargets() or withTargetEndpoints()完成的

代码语言:javascript
复制
peers = ["peer1.org1.example.com","peer1.org2.example.com"]
req := InstantiateCCRequest{Name: "name", Version: "version", Path: "path", Policy: ccPolicy}
, err := rc.InstantiateCC("mychannel", req, WithTargets(peers...))

cli调用中也使用了类似的逻辑,man to chaincode instantiate给出(查找NOTICE --->,我已经标记了required标志):

代码语言:javascript
复制
Deploy the specified chaincode to the network.

Usage:
  peer chaincode instantiate [flags]

Flags:
  -C, --channelID string               The channel on which this command should be executed
      --collections-config string      The fully qualified path to the collection JSON file including the file name
      --connectionProfile string       Connection profile that provides the necessary connection information for the network. Note: currently only supported for providing peer connection information
  -c, --ctor string                    Constructor message for the chaincode in JSON format (default "{}")
  -E, --escc string                    The name of the endorsement system chaincode to be used for this chaincode
  -h, --help                           help for instantiate
  -l, --lang string                    Language the chaincode is written in (default "golang")
  -n, --name string                    Name of the chaincode
"NOTICE--->"   --peerAddresses stringArray      The addresses of the peers to connect to
  -P, --policy string                  The endorsement policy associated to this chaincode
      --tlsRootCertFiles stringArray   If TLS is enabled, the paths to the TLS root cert files of the peers to connect to. The order and number of certs specified should match the --peerAddresses flag
  -v, --version string                 Version of the chaincode specified in install/instantiate/upgrade commands
  -V, --vscc string                    The name of the verification system chaincode to be used for this chaincode

Global Flags:
      --cafile string                       Path to file containing PEM-encoded trusted certificate(s) for the ordering endpoint
      --certfile string                     Path to file containing PEM-encoded X509 public key to use for mutual TLS communication with the orderer endpoint
      --clientauth                          Use mutual TLS when communicating with the orderer endpoint
      --connTimeout duration                Timeout for client to connect (default 3s)
      --keyfile string                      Path to file containing PEM-encoded private key to use for mutual TLS communication with the orderer endpoint
  -o, --orderer string                      Ordering service endpoint
      --ordererTLSHostnameOverride string   The hostname override to use when validating the TLS connection to the orderer.
      --tls                                 Use TLS when communicating with the orderer endpoint
      --transient string                    Transient map of arguments in JSON encoding```
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55068481

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档