1
0
mirror of https://github.com/romanz/electrs.git synced 2024-11-19 09:54:09 +01:00
An efficient re-implementation of Electrum Server in Rust
Go to file
2018-06-28 00:20:24 +03:00
examples Rename parse into bulk 2018-06-28 00:20:24 +03:00
src Rename parse into bulk 2018-06-28 00:20:24 +03:00
tools Remove 0MQ Python client 2018-05-24 20:45:54 +03:00
.gitignore Ignore other DB directories 2018-06-12 00:01:20 +03:00
.travis.yml Don't build on nightly Rust 2018-05-17 12:28:40 +03:00
Cargo.toml Allow listing bitcoind blk*.dat files 2018-06-21 22:03:01 +03:00
LICENSE Add MIT license and small README 2018-04-08 23:54:29 +03:00
README.md Log only to stderr 2018-06-18 12:23:19 +03:00
TODO.md Add mempool limiting TODO 2018-06-26 18:52:06 +03:00

Electrum Server in Rust

Build Status

An efficient re-implementation of Electrum Server, inspired by ElectrumX and Electrum Personal Server.

The motivation behind this project is to enable a user to run his own Electrum server, with required hardware resources not much beyond those of a full node. The server indexes the entire Bitcoin blockchain, and the resulting index enables fast queries for any given user wallet, allowing the user to keep real-time track of his balances and his transaction history using the Electrum wallet. Since it runs on the user's own machine, there is no need for the wallet to communicate with external Electrum servers, thus preserving the privacy of the user's addresses and balances.

Features

  • Supports Electrum protocol v1.2
  • Maintains an index over transaction inputs and outputs, allowing fast balance queries
  • Fast synchronization of the Bitcoin blockchain (~5 hours for ~184GB @ June 2018) on modest hardware (without SSD)
  • Low index storage overhead (~20%), relying on a local full node for transaction retrieval
  • Efficient mempool tracker (allowing better fee estimation)
  • Low CPU & memory usage (after initial indexing)
  • txindex is not required for the Bitcoin node
  • Uses a single RocksDB database, for better consistency and crash recovery

Usage

Install latest Rust (1.26+) and latest Bitcoin Core (0.16+).

$ sudo apt update
$ sudo apt install clang

# Allow Bitcoin daemon to sync before starting Electrum server
$ bitcoind -server=1 -daemon=0 -txindex=0 -prune=0

# First build should take ~20 minutes
$ cargo build --release
$ cargo run --release -- -vvv -l debug.log
Config { verbosity: 3, network_type: Mainnet, db_path: "/home/roman/Code/Bitcoin/elect-rs/db/mainnet", rpc_addr: V4(127.0.0.1:50001), monitoring_addr: V4(127.0.0.1:42024) }
DEBUG - BlockchainInfo { chain: "main", blocks: 528021, headers: 528021, bestblockhash: "0000000000000000000e322bbf044887078ddc6228e9c7c7f5c5bd93ccd8dab6", size_on_disk: 196239576671, pruned: false }
DEBUG - opening ./db/mainnet with StoreOptions { bulk_import: true }
DEBUG - applying 0 new headers from height 0
INFO - best=0000000000000000001134b741f53f4e49e9f8073e41af6d8aaad3b849ebeee4 height=527673 @ 2018-06-16T04:03:53Z (527674 left to index)
# <initial indexing takes a few hours>
DEBUG - applying 527674 new headers from height 0
INFO - starting full compaction
# <full compaction happens once, and may take ~1 hour>
INFO - finished full compaction
DEBUG - closing ./db/mainnet
DEBUG - opening ./db/mainnet with StoreOptions { bulk_import: false }
INFO - RPC server running on 127.0.0.1:50001

# The index database is stored here:
$ du db/
36G db/mainnet/

# Connect only to the local server, for better privacy
$ electrum  --oneserver --server=127.0.0.1:50001:t

Monitoring

Indexing and serving metrics are exported via Prometheus:

$ sudo apt install prometheus
$ echo "
scrape_configs:
  - job_name: electrs
    static_configs:
    - targets: ['localhost:42024']
" | 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'