yoshuki43's blog

Testnet用にKotoのInsightをインストールする

準備

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#kotod/bitcore-nodeコンパイルに必要なもの
sudo apt-get update
sudo apt-get install build-essential pkg-config libc6-dev m4 g++-multilib \
    autoconf libtool ncurses-dev unzip git python python-zmq zlib1g-dev \
    wget bsdmainutils automake curl libzmq3-dev

#Node.js一式
curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash -
sudo apt-get install -y nodejs

#ソースダウンロード
git clone https://github.com/wo01/koto
git clone https://github.com/wo01/bitcore-node-koto
git clone https://github.com/wo01/insight-api-koto
git clone https://github.com/wo01/insight-ui-koto

インストール

Insight用のKotodをコンパイル

insightではgetblockhashes等、通常のKotodでサポートしていない(削除された?)RPCコマンドを使用するため、特別なバージョンのKotodが必要です。

上記リポジトリのブランチにinsight用のKotodが入っています。

非公式Testnetを使う場合は、ここでdnsseedの設定を変更しておきましょう。

1
2
vi koto/src/chainparam.cpp
 ...

※詳細は前回の記事を参照のこと。

コンパイル手順:

1
2
3
4
cd koto
git checkout v1.0.14-bitcore
./zcutil/build.sh --disable-rust
cp src/kotod ../bitcore-node-koto/bin/

※「~/.zcash-params」の準備も忘れずに。

bitcore-node-kotoの準備

1
2
cd ../bitcore-node-koto
npm install

ノード作成とUIプラグインのインストール

1
2
3
4
5
cd ..
./bitcore-node-koto/bin/bitcore-node create testnet
cd testnet
../bitcore-node-koto/bin/bitcore-node install ../insight-api-koto
../bitcore-node-koto/bin/bitcore-node install ../insight-ui-koto

設定

networkをtestnetにします。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
{
  "network": "testnet",
  "port": 3001,
  "services": [
    "bitcoind",
    "insight-api-koto",
    "insight-ui-koto",
    "web"
  ],
  "servicesConfig": {
    "bitcoind": {
      "spawn": {
        "datadir": "./data",
        "exec": "/home/koto/bitcore-node-koto/bin/kotod"
      }
    }
  }
}

とりあえず実行してみる

1
../bitcore-node-koto/bin/bitcore-node start

以下のことを確認する。

Ctrl-Cで終了

kotod設定

初期設定のままだとbitcore-node(insight)のログと一緒にkotodの出力が表示さててしまい、非常にうざいので、kotodの表示を止めます。

vi data/koto.conf

1
2
#これを最後の行に追加
showmetrics=0

systemdで起動

前提

  • kotoユーザで実行
  • ホームディレクトリ直下に、上記手順でインストールした

/etc/systemd/system/insight.conf

1
2
3
4
5
6
7
8
9
10
11
12
13
[Unit]
Description = Koto Blockchain Explorer

[Service]
ExecStart = /home/koto/bitcore-node-koto/bin/bitcore-node start
WorkingDirectory=/home/koto/testnet
Restart = always
Type = simple
User=koto
Group=koto

[Install]
WantedBy = multi-user.target

実行

1
2
3
sudo systemctl daemon-reload
sudo systemctl enable insight
sudo systemctl start insight

確認

1
2
3
4
5
6
7
8
$ systemctl status insight
● insight.service - Koto Blockchain Explorer
   Loaded: loaded (/etc/systemd/system/insight.service; disabled)
   Active: active (running) since Sat 2018-03-17 13:56:29 JST; 28min ago
 Main PID: 13350 (bitcore)
   CGroup: /system.slice/insight.service
           ├─13350 bitcore
           └─13361 /home/koto/bitcore-node-koto/bin/kotod --conf=/home/koto/testnet/data/koto.conf --datadir=/home/koto/...

追記

アクセスするURLを/insight/から/に変えたい。

bitcore-node.jsonを以下のように変える。

1
2
3
4
5
6
7
8
9
service {
    :
  "servicesConfig": {
      :
    "insight-ui-koto": {
      "routePrefix": ""
    }
  }
}

apiのURLを変えた場合は、apiPrefixも設定する必要があると思われる。(未確認)

insightが使用するkotodが使用するポートを変えたい

P2PポートとRPCポートだけでいいならdata/koto.confに以下を追加すればよい。

1
2
port=12345
rcpport=12346

Comments