LoginSignup
15
13

More than 5 years have passed since last update.

bitcore-nodeの導入方法(ブロックエクスプローラーinsightの導入方法)

Last updated at Posted at 2015-11-02

bitcore-node

  • bitcore-node v3.1.2を対象にしています

bitcore-nodeとは?

bitpayが開発したオープンソースなビットコインフルノードです。
bitcoindをnode.jsに内包していてp2pネットワーク、ブロックチェーンがjavascriptから扱いやすい構造になっています
bitpayが開発しているプロダクト(insight-api,bitcoin-wallet-service)は、bitcore-node上のプラグインとして実装されています

bitcore-lib、bitcore-nodeを使えばビットコインについてjavascriptからほとんどの機能を直接あつかえるようになります。
それらをパッケージ化してbitcoreと呼んでいるようです

https://bitcore.io
https://github.com/bitpay/bitcore-node

事前準備

動作環境

Node.js v0.12.7 or v4.4.x
~100GB of disk storage
~4GB of RAM
Mac OS X >= 10.9, Ubuntu >= 12.04 (libc >= 2.15 and libstdc++ >= 6.0.16)

※ec2の場合ブロックチェーン同期後ならt2.smallでなんとか動く、テストネットならt2.microでも。。。
※公式にはcentos7の記載はないが動きます
※現状ディスクは400GB以上確保したほうが良いです

ubuntu14.04LTS事前用意

apt-get install build-essential libtool autotools-dev automake autoconf pkg-config libssl-dev git
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.29.0/install.sh | bash
nvm install v0.12

centos7事前用意

zeromqのインストール
yum install -y zeromq3-devel

install

npm install -g bitcore-node

ブロックチェーンディレクトリを作成

bitcore-node create mynode

ディレクトリ構成

mynode/
 data/
  blocks/           ブロックチェーン
  bitcore-node.db/  bitcoreメタデータ
  node_modules/     nodejsプラグイン
  chainstate/       UTXOやメタデータ

bitcoind設定

bitcoindの設定もある
接続数変更したいときなどに変更する

mynode/data/bitcoin.conf
maxconnections=16
whitelist=127.0.0.1
txindex=1
addressindex=1
timestampindex=1
spentindex=1
zmqpubrawtx=tcp://127.0.0.1:28332
zmqpubhashblock=tcp://127.0.0.1:28332
rpcallowip=127.0.0.1
rpcuser=bitcoin
rpcpassword=local321
uacomment=bitcore

※v3から設定しなければならないオプションが増えた

プラグインインストール(任意)

cd mynode
bitcore-node install insight-api insight-ui

起動

cd mynode
bitcore-node start --daemon

※ブロックチェーンの同期には時間がかかります

同期の確認

tail -f mynode/data/debug.log

自動再起動スクリプト

centos7

/etc/systemd/system/bitcore-node.service
[Unit]
Description=bitcore-node
After=syslog.target network.target

[Service]
Type=simple
ExecStart=/bin/bitcore-node start -c /home/centos/bitcore/mynode/bitcore-node.json
WorkingDirectory=/home/centos/bitcore/mynode
KillMode=control-group
Restart=always
User=centos
Group=centos

[Install]
WantedBy=multi-user.target
  • 起動・終了方法
systemctl start bitcore-node
systemctl stop bitcore-node

※v3系から子プロセスが起動する関係でstopしてもbitcoindが止まらないのでKillMode=control-groupを設定する

その他

bitcoindのバージョンは0.12.1

やったほうがいいOSチューニング

/etc/sysctl.d/01-tune.conf
net.core.rmem_max = 16777216
net.core.rmem_default = 16777216
net.core.netdev_max_backlog = 16384
net.core.somaxconn = 16384
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_max_orphans = 262144
net.ipv4.tcp_max_syn_backlog = 262144
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syn_retries = 2
net.ipv4.tcp_fin_timeout = 5
net.ipv4.tcp_tw_reuse = 1
net.ipv4.ip_local_port_range = 20000 60000
vm.overcommit_ratio=99
vm.overcommit_memory=2
vm.swappiness = 1

おまけ insight 導入サイト

https://insight.bitpay.com/
https://bitcore2.mytrezor.com/
https://blockexplorer.com/
https://insight.satoshipay.io/insight/
https://www.localbitcoinschain.com/

15
13
6

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
15
13