1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[HLF]のchaincodeインストール方法が"Fabric chaincode lifecycle"に変わった

Last updated at Posted at 2020-07-03

chaincodeのインストール方法が、V1.4から変化していたのでメモします。

V2.xから"Fabric chaincode lifecycle"という方法になっていました。
手順が増えているので備忘録として残します。
TLS:Enableだとコマンドラインがゴチャゴチャするので、TLS:Disabledとします。基本は変わらずTLS関連のオプションが増えるだけです。
Organization(Org1) + Peer(Peer0)分だけ書いておきます。

V1.4はどうだったか?

  1. channelをcreateして
  2. createしたchannelにjoinして
  3. chaincodeをインストールして
  4. chaincodeをinstantiate(同時にInitLedgerの呼び出し)します

この4ステップでした。
chaincodeのソースファイルは予め所定の場所へコピーしておきます(ソースがgolangの場合)。

peer channel create -o orderer-example-com:30050 -c mychannel -f ./channel.tx
peer channel join -b mychannel.block
peer chaincode install -n asset -v 1.0 -p github.com/asset
peer chaincode instantiate -o orderer-example-com:30050 -C mychannel -n asset -v 1.0 -c ...

シンプルです。

"Fabric chaincode lifecycle"でどう変わったか

joinまでは同じですが、そこからかなり手順が増えています。fabric-sampleのシェルを追って書いているので、不要な処理が入っているかもしれません(チェックなど)。

  1. channelをcreateして
  2. createしたchannelにjoinして
  3. channelをupdateして
  4. [lifecycle] chaincodeを.tar.gzファイルへpackageして
  5. [lifecycle] packageした.tar.gzファイルをinstallして
  6. [lifecycle] chaincodeをpackage-idでapproveformyorg(?)して
  7. [lifecycle] chaincodeをcommitできるかチェックして(checkcommitreadiness)
  8. [lifecycle] chaincodeをcommitして
  9. chaincodeをisInitオプションでInitLedgerをinvokeします

手順が倍以上に増えていました。

peer channel create -o orderer-example-com:30050 -c mychannel -f channel.tx --outputBlock mychannel.block
peer channel join -b mychannel.block
peer channel update -o orderer-example-com:30050 -c mychannel -f Org1MSPanchors.tx
peer lifecycle chaincode package asset.tar.gz --path ${CC_SRC_PATH} --lang ${CC_RUNTIME_LANGUAGE} --label asset_${VERSION}
peer lifecycle chaincode install asset.tar.gz
peer lifecycle chaincode approveformyorg -o orderer-example-com:30050 --channelID mychannel --name asset --version ${VERSION} --init-required --package-id ${PACKAGE_ID} --sequence ${SEQUENCE} --init-required
peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name asset --version ${VERSION} --sequence ${SEQUENCE} --output json --init-required
peer lifecycle chaincode commit -o orderer-example-com:30050 --channelID mychannel --name asset --peerAddresses peer0-org1-example-com:30151 --peerAddresses peer0-org2-example-com:30351 --version ${VERSION} --sequence ${SEQUENCE} --init-required
peer chaincode invoke -o orderer-example-com:30050 -C mychannel -n asset --peerAddresses peer0-org1-example-com:30151 --peerAddresses peer0-org2-example-com:30351 --isInit -c ...

ソースファイルは指示した場所に置いてあれば、package化して所定の場所へコピーしてくれます。

さいごに

解読に疲れた…

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?