1
0
mirror of https://github.com/romanz/electrs.git synced 2024-11-19 09:54:09 +01:00
electrs/doc/usage.md

3.3 KiB

Installation

Install latest Rust (1.26+), latest Bitcoin Core (0.16+) and latest Electrum wallet (3.2+).

Also, install the following packages (on Debian):

$ sudo apt update
$ sudo apt install clang cmake  # for building 'rust-rocksdb'

Build

First build should take ~20 minutes:

$ cargo build --release

Bitcoind configuration

Allow Bitcoin daemon to sync before starting Electrum server:

$ bitcoind -server=1 -txindex=0 -prune=0

If you are using -rpcuser=USER and -rpcpassword=PASSWORD for authentication, please use --cookie="USER:PASSWORD" command-line flag. Otherwise, ~/.bitcoin/.cookie will be read, allowing this server to use bitcoind JSONRPC interface.

Usage

First index sync should take ~2 hours:

$ cargo run --release -- -vvv --timestamp --db-dir ./db [--cookie="USER:PASSWORD"]
2018-07-12T21:30:46 - DEBUG - BlockchainInfo { chain: "main", blocks: 531645, headers: 531645, bestblockhash: "00000000000000000006e41b275b21fc44e3b7afa8a8092aa6a7e4b84345f1f1", size_on_disk: 199667678141, pruned: false }
2018-07-12T21:30:46 - DEBUG - opening "./db/mainnet" with StoreOptions { bulk_import: true }
2018-07-12T21:30:46 - INFO - indexing 1313 blk*.dat files
2018-07-12T21:30:58 - DEBUG - applying 531646 new headers from height 0
2018-07-12T22:34:36 - DEBUG - last indexed block: best=00000000000000000006e41b275b21fc44e3b7afa8a8092aa6a7e4b84345f1f1 height=531645 @ 2018-07-12T18:20:51Z
2018-07-12T22:34:37 - INFO - starting full compaction
2018-07-12T23:18:53 - INFO - finished full compaction
2018-07-12T23:18:53 - DEBUG - opening "./db/mainnet" with StoreOptions { bulk_import: false }
2018-07-12T23:19:05 - DEBUG - applying 531646 new headers from height 0
2018-07-12T23:19:05 - DEBUG - downloading new block headers (531646 already indexed) from 0000000000000000002face92073e7b1dbcb02df32ea891b187a6c10b37dc8ad
2018-07-12T23:19:06 - INFO - best=0000000000000000002face92073e7b1dbcb02df32ea891b187a6c10b37dc8ad height=531656 @ 2018-07-12T20:07:12Z (11 left to index)
2018-07-12T23:19:08 - DEBUG - applying 11 new headers from height 531646
2018-07-12T23:19:11 - INFO - RPC server running on 127.0.0.1:50001

The index database is stored here:

$ du db/
37G db/mainnet/

Electrum client

# Connect only to the local server, for better privacy
$ ./scripts/local-electrum.bash
+ ADDR=127.0.0.1
+ PORT=50001
+ PROTOCOL=t
+ electrum --oneserver --server=127.0.0.1:50001:t
<snip>

In order to use a secure connection, TLS-terminating proxy (e.g. hitch) is recommended:

$ hitch --backend=[127.0.0.1]:50001 --frontent=[127.0.0.1]:50002 pem_file
$ electrum --oneserver --server=127.0.0.1:50002:s

Monitoring

Indexing and serving metrics are exported via Prometheus:

$ sudo apt install prometheus
$ echo "
scrape_configs:
  - job_name: electrs
    static_configs:
    - targets: ['localhost:4224']
" | sudo tee -a /etc/prometheus/prometheus.yml
$ sudo systemctl restart prometheus
$ firefox 'http://localhost:9090/graph?g0.range_input=1h&g0.expr=index_height&g0.tab=0'