本ファイルは、付録で入力するコマンドなどを記述しています。

[A.3.2 複数Peer構成の構築手順（Dockerホストにて）]
*Dockerのインストールが完了した状態からスタートします

cd ~/
sudo apt install git
sudo git clone https://github.com/hyperledger/iroha --depth=1

cd ~/iroha/example
sudo sh -c "echo -n 8b3a90abfd18b8e6ffef30cbdac4ef68bfbce191ca5799ca70f14f46ae94fdf1 > node1.priv"
sudo sh -c "echo -n 42b86a5b5eef5146ae9fc4191ece5cfb23c650be2b291200e6dc4fe34aa5638e > node1.pub"
sudo sh -c "echo -n 19b42196c71c8a02cc4c708c505b62f7ac138062634f63bc7fdac4c2bcd54c6a > node2.priv"
sudo sh -c "echo -n 3b3f83ca158a4ca2aaf6e6bfedc976ead0753f4ce466f78504f3509d121ffe8a > node2.pub"

sudo mv config.docker config.docker.org
sudo cp config.sample config.docker
sudo sed -i s#/path/to/wsv/folder#/tmp/block_store/# config.docker

cd ~/iroha
sudo cp example/ example1/ -r
sudo cp example/ example2/ -r

cd ~/
sudo docker network create iroha-network
sudo docker volume create blockstore
sudo docker volume create blockstore1
sudo docker volume create blockstore2


irohaコンテナ作成（作成後にexitします）
sudo docker run -it --name iroha \
-p 51051:50051 \
-v $(pwd)/iroha/example:/opt/iroha_data \
-v blockstore:/tmp/block_store \
--network=iroha-network \
--entrypoint=/bin/bash \
hyperledger/iroha:1.3.0

exit

iroha1コンテナ作成（作成後にexitします）
sudo docker run -it --name iroha1 \
-p 52051:50051 \
-v $(pwd)/iroha/example1:/opt/iroha_data \
-v blockstore1:/tmp/block_store \
--network=iroha-network \
--entrypoint=/bin/bash \
hyperledger/iroha:1.3.0

exit

iroha2コンテナ作成（作成後にexitします）
sudo docker run -it --name iroha2 \
-p 53051:50051 \
-v $(pwd)/iroha/example2:/opt/iroha_data \
-v blockstore2:/tmp/block_store \
--network=iroha-network \
--entrypoint=/bin/bash \
hyperledger/iroha:1.3.0

exit

config.dockerはすでに準備済です。
*サンプルファイル「Iroha_Sample2.zip」のpeerをコピーしても結構です。

[A.3.4 複数Peer構成の起動手順]

Dockerホストにて各コンテナを起動
sudo docker start iroha iroha1 iroha2

irohaコンテナにてirohadプロセス起動
sudo docker exec -it iroha /bin/bash
irohad --config config.docker --genesis_block genesis.block --keypair_name node0

iroha1コンテナにてirohadプロセス起動
sudo docker exec -it iroha1 /bin/bash
irohad --config config.docker --genesis_block genesis.block --keypair_name node1

iroha2コンテナにてirohadプロセス起動
sudo docker exec -it iroha2 /bin/bash
irohad --config config.docker --genesis_block genesis.block --keypair_name node2


[A.3.6 複数Peer構成で同期しない場合の対処]

irohaコンテナ、iroha1コンテナ、iroha2コンテナのirohadプロセスを停止（Ctrl ＋ C を入力）

irohaコンテナにてirohadプロセス再起動(2021年12月21日時点で--overwrite_ledgerで初期化されないため事前にWSVを手動で削除)
rm /tmp/block_store/* -r
irohad --config config.docker --genesis_block genesis.block --keypair_name node0 --overwrite_ledger

iroha1コンテナにてirohadプロセス再起動(2021年12月21日時点で--overwrite_ledgerで初期化されないため事前にWSVを手動で削除)
rm /tmp/block_store/* -r
irohad --config config.docker --genesis_block genesis.block --keypair_name node1 --overwrite_ledger

iroha2コンテナにてirohadプロセス再起動(2021年12月21日時点で--overwrite_ledgerで初期化されないため事前にWSVを手動で削除)
rm /tmp/block_store/* -r
irohad --config config.docker --genesis_block genesis.block --keypair_name node2 --overwrite_ledger


[A.3.7 複数Peer構成のブロックチェーンの同期確認]

irohaコンテナにて２つのトランザクション実施と確認(Terminal A-3-3)
sudo docker exec -it iroha /bin/bash
iroha-cli -account_name admin@test
> : 1
> : 16
coin#test
333.22
> : 4


> : 1
> : 5
admin@test
test@test
coin#test
111.11
> : 4


> : 2
> : 7
トランザクションのハッシュ値①
> : 1


> : 2
> : 7
トランザクションのハッシュ値②
> : 1


> : Ctrl+C
exit

iroha1コンテナにてトランザクションの確認(Terminal A-3-4)
sudo docker exec -it iroha1 /bin/bash
iroha-cli -account_name admin@test
> : 2
> : 7
トランザクションのハッシュ値①
> : 1


> : 2
> : 7
トランザクションのハッシュ値②
> : 1


> : Ctrl+C
exit

iroha2コンテナにてトランザクションの確認(Terminal A-3-5)
sudo docker exec -it iroha2 /bin/bash
iroha-cli -account_name admin@test
> : 2
> : 7
トランザクションのハッシュ値①
> : 1


> : 2
> : 7
トランザクションのハッシュ値②
> : 1


> : Ctrl+C
exit

[A.3.8 複数Peer構成の停止手順]

irohaコンテナ、iroha1コンテナ、iroha2コンテナのirohadプロセスを停止（Ctrl ＋ C を入力）

Dockerホストにて各コンテナを停止
sudo docker stop iroha iroha1 iroha2

[A.4.3 異なるバージョンが混在するHyperledger Irohaネットワーク]
*注意：バージョン1.2.0以降と未満のバージョンを混在することはできません。
       バージョン1.2.0以降と未満のバージョンではiroha-cliのメニュー番号が異なります

irohaコンテナ作成（バージョン1.2.0の作成）(Terminal A-4-1)
sudo docker run -it --name iroha \
-p 51051:50051 \
-v $(pwd)/iroha/example:/opt/iroha_data \
-v blockstore:/tmp/block_store \
--network=iroha-network \
--entrypoint=/bin/bash \
hyperledger/iroha:1.2.0

iroha1コンテナ作成（バージョン1.2.0の作成）(Terminal A-4-2)
sudo docker run -it --name iroha1 \
-p 52051:50051 \
-v $(pwd)/iroha/example1:/opt/iroha_data \
-v blockstore1:/tmp/block_store \
--network=iroha-network \
--entrypoint=/bin/bash \
hyperledger/iroha:1.2.0

iroha2コンテナ作成（バージョン1.3.0の作成）(Terminal A-4-3)
sudo docker run -it --name iroha2 \
-p 53051:50051 \
-v $(pwd)/iroha/example2:/opt/iroha_data \
-v blockstore2:/tmp/block_store \
--network=iroha-network \
--entrypoint=/bin/bash \
hyperledger/iroha:1.3.0

Dockerホストにて確認(Terminal A-4-4)
sudo docker ps
