Hyperledger Fabric 管理链码 peer lifecycle chaincode 指令使用

Hyperledger Fabric 管理链码 peer lifecycle chaincode 指令使用

链上代码(Chaincode)简称链码,包括系统链码和用户链码。系统链码(System Chaincode)指的是Fabric Peer中负责系统配置、查询、背书、验证等平台功能的代码逻辑,运行在Peer进程内,将在第14章介绍。用户链码指的是用户编写的用来实现智能合约的应用代码。如无特殊说明,链码一般指的就是用户链码。

链码被部署在Peer节点上,运行在独立的沙盒(目前为Docker容器)中,并通过gRPC协议与相应的Peer节点进行交互。用户可以通过命令行或SDK调用链码方法,链码被调用时,会按照链码内预定逻辑来计算账本状态的更新集合(读写集合)。

链码操作命令

Operate a chaincode: install|instantiate|invoke|package|query|signpackage|upgrade|list.

Usage:
  peer chaincode [command]

Available Commands:
  install     Install a chaincode.
  instantiate Deploy the specified chaincode to the network.
  invoke      Invoke the specified chaincode.
  list        Get the instantiated chaincodes on a channel or installed chaincodes on a peer.
  package     Package a chaincode
  query       Query using the specified chaincode.
  signpackage Sign the specified chaincode package
  upgrade     Upgrade chaincode.

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)
  -h, --help                                help for chaincode
      --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
      --tlsHandshakeTimeShift duration      The amount of time to shift backwards for certificate expiration checks during TLS handshakes with the orderer endpoint
      --transient string                    Transient map of arguments in JSON encoding

Use "peer chaincode [command] --help" for more information about a command.

最简单的操作链码的方式是使用命令行。Fabric自2.0版本开始正式启用新的生命周期系统链码(位于core/chaincode/lifecycle)来管理链码(需开启应用能力V2_0),客户端通过新的 peer lifecycle chaincode 子命令(位于internal/peer/lifecycle)对链码进行打包、安装、批注和提交等生命周期管理,取代1.x中的 peer chaincode 命令。

相对1.x版本中的模式,新的链码管理从单个组织升级为通道范畴。例如,链码的背书策略可由通道内多个组织来商定,部署和升级也作为通道层面的操作,这些都提高了链码生命周期的安全性。如果要对链码进行调用或查询,仍可以使用原有的peer chaincode invoke peer chaincode query 命令。

如果要使用1.x版本中的链码生命周期管理(peer chaincodeinstall/instantaite/upgrade/list等命令),需要将通道的应用能力版本设置为兼容的低版本,如V1_4_2。当通道启用了应用能力V2_0后,将无法再部署或升级原有模式下的链码。

链码生命周期:

链码操作支持全局命令选项:

全局选项 类型 含义
--cafile string 信任的排序服务的 TLS CA 的证书(PEM编码格式)路径
--certfile string 与排序服务进行双向 TLS 认证时使用的本地证书文件路径
--clientauth bool 与排序服务通信时是否启用双向 TLS 认证
--connTimeout duration 客户端连接超时,默认为 3 秒
--keyfile string 与排序服务双向 TLS 认证时使用的本地私钥文件路径
-o,--orderer string Orderer 服务地址
--order
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值