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

[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 8b3a90abfd18b8e6ffef30cbdac4ef68bfbce191ca5799ca70f14f46ae94fdf1 > node1.priv"
sudo sh -c "echo 42b86a5b5eef5146ae9fc4191ece5cfb23c650be2b291200e6dc4fe34aa5638e > node1.pub"
sudo sh -c "echo 19b42196c71c8a02cc4c708c505b62f7ac138062634f63bc7fdac4c2bcd54c6a > node2.priv"
sudo sh -c "echo 3b3f83ca158a4ca2aaf6e6bfedc976ead0753f4ce466f78504f3509d121ffe8a > node2.pub"

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

本書の内容に沿って、設定ファイルを書き換えます。
*サンプルフィアルのpeer0からpeer2をコピーしても結構です。

some-postgresコンテナ作成
sudo docker run --name some-postgres \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=mysecretpassword \
-p 15432:5432 \
--network=iroha-network \
-d postgres:9.5

some-postgres1コンテナ作成
sudo docker run --name some-postgres1 \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=mysecretpassword \
-p 25432:5432 \
--network=iroha-network \
-d postgres:9.5

some-postgres2コンテナ作成
sudo docker run --name some-postgres2 \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=mysecretpassword \
-p 35432:5432 \
--network=iroha-network \
-d postgres:9.5

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.0.1

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.0.1

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.0.1

exit


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

Dockerホストにて各コンテナを起動
sudo docker start some-postgres some-postgres1 some-postgres2
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プロセス再起動
irohad --config config.docker --genesis_block genesis.block --keypair_name node0 --overwrite_ledger

iroha1コンテナにてirohadプロセス再起動
irohad --config config.docker --genesis_block genesis.block --keypair_name node1 --overwrite_ledger

iroha2コンテナにてirohadプロセス再起動
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
> : 2


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


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


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


> : Ctrl+C
exit

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


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


> : Ctrl+C
exit

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


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


> : Ctrl+C
exit

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

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

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

[A.4.3 異なるバージョンが混在するHyperledger Irohaネットワーク]

irohaコンテナ作成（バージョン1.1.1の作成）(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.1.1

iroha1コンテナ作成（バージョン1.1.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.1.0

iroha2コンテナ作成（バージョン1.0.1の作成）(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.0.1

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