Setup Trezor Blockbook (Viacoin)
Blockbook is an address or account balance backend (or blockchain indexer) for Trezor Wallet, developed by SatoshiLabs, which you can install and run on your computer. With Trezor Wallet installed and running as a local instance, you can be completely independent from connecting to the SatoshiLabs servers. It looks a lot like insight explorer.
This guide will show how to setup a Blockbook server on Debian for public usage.
You can use a VPS on Vultr. It’s a great site and you can pay with either credit/debit card or bitcoin.
Vultr: High Performance SSD Cloud.
VULTR Global Cloud Hosting - Brilliantly Fast SSD VPS Cloud Servers. 100% KVM Virtualization
After deploying, Let’s start with updating our Debian system
apt-get install update
The purpose of creating a swap is to provide disk storage to the kernel when RAM is under pressure. It allows for the kernel to move memory pages that are not likely to be accessed soon to disk, freeing memory. Our server has only 1GB RAM, it’s not a lot so that is why we need a swap for sure. The downside of swapping is that disks are slow. RAM is magnitudes faster. However using a swap can be the difference of your server crashing because it doesn’t have enough RAM or staying online.
Let’s create a Swap file. The fastest way is by using fallocate. We will use a 4GB swap (There’s no perfect number).
fallocate -l 4G /swapfile
We should adjust the permission on the swap file so that it is not readable by anone besides root. We can use chmod to lock down permissions.
chmod 600 /swapfile
Now the swap file is created, the system should format this file as a swap & enable it.
mkswap /swapfileswapon /swapfile
Now we have to make the swapfile permanent. So we still have it when the system reboots.
# echo “/swapfile swap swap sw 0 0” >> /etc/fstab
Now we can do some tweaking. Swapiness param determines how often the system swaps datta out of memory to the swap. This value is between 0 & 100% (The percentage of memory that will trigger the use of swap). Lets change this to 10.
and to make it pernament
echo “vm.swappiness = 10” >> /etc/sysctl.conf
Now it’s time to install all required deps
apt-get install build-essential libssl-dev libboost-all-dev libdb5.3 libdb5.3-dev libdb5.3++-dev libtool automake libevent-dev bsdmainutils git ntp make g++ gcc autoconf cpp ngrep iftop sysstat autotools-dev pkg-config libminiupnpc-dev libzmq3-dev apt-transport-https ca-certificates curl gnupg2 software-properties-common -y
Add this repository with the command
curl -s https://download.docker.com/linux/debian/gpg | apt-key add && add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" && apt-get update
Now to install docker
apt-get install docker-ce -y
Git clone blockbook, cd into it and make
git clone https://github.com/trezor/blockbook && cd blockbookmake all-viacoincd buildapt install ./blockbook-viacoin_0.3.1_amd64.deb ./backend-viacoin_0.16.3-satoshilabs-1_amd64.deb -ysystemctl start backend-viacoin
systemctl enable backend-viacoin
*apt-install blockbook-viacoin (versions can differ. Use tab or ls to know)
viacoin core will start to sync now. Meanwhile blockbook can be started.
systemctl start blockbook-viacoinsystemctl enable blockbook-viacoin
HAProxy, which stands for High Availability Proxy, is a popular open source software TCP/HTTP Load Balancer and proxying solution which can be run on Linux, Solaris, and FreeBSD. Its most common use is to improve the performance and reliability of a server environment by distributing the workload across multiple servers (e.g. web, application, database). It is used in many high-profile environments, including: GitHub, Imgur, Instagram, and Twitter.
We will use Haproxy instead of Nginx since it’s a better load balancer and don’t need a build-in webserver like Nginx provides.
apt-get install haproxy
Now we need to append these lines to Haproxy (end of the file)
default_backend backendnodesbackend backendnodes
server node1 127.0.0.1:9155 ssl verify none
Please not ports for other assets are not 9155. Check https://github.com/trezor/blockbook/blob/master/docs/ports.md
After that you can start & enable haproxy
systemctl start haproxy
systemctl enable haproxy
You can later setup more blockbook servers and add the nodes to the config file & restart haproxy.
It should balance the load between the servers and if 1 of them goes down, switch to another blockbook server.
Blockbook can now be viewed on blockbook.viacoin.org
Obviously you have to have your own domain for it. For SSL we use Cloudflare Flexible SSL.
A lot of this comes from the groestlcoin blockbook setup guide (their guide uses Nginx with certbot): https://groestlcoin.org/forum/index.php?topic=1036.0