Git Product home page Git Product logo

electrs's Introduction

Esplora - Electrs backend API

A block chain index engine and HTTP API written in Rust based on romanz/electrs.

Used as the backend for the Esplora block explorer powering blockstream.info.

API documentation is available here.

Documentation for the database schema and indexing process is available here.

Installing & indexing

Install Rust, Bitcoin Core and the clang and cmake packages, then:

$ git clone https://github.com/blockstream/electrs && cd electrs
$ git checkout new-index
$ cargo run --release --bin electrs -- -vvvv --daemon-dir ~/.bitcoin

# Or for liquid:
$ cargo run --features liquid --release --bin electrs -- -vvvv --daemon-dir ~/.liquid

See electrs's original documentation for more detailed instructions. Note that our indexes are incompatible with electrs's and has to be created separately.

The indexes require 440GB of storage after running compaction, but you'll need to have about 1TB of free space available for the initial (non-compacted) indexing process. Creating the indexes should take a few hours on a beefy machine with SSD.

Note: the pre-v2 version supported a "light" indexing mode for personal use, where less data is kept on-disk in exchange for a performance hit and more reliance/load on bitcoind. This option is not currently available, but can be enabled with an older esplora release. We're hoping to eventually get this feature back. Let us know if you find this important!

To deploy with Docker, follow the instructions here.

Notable changes from Electrs:

  • HTTP REST API instead of the Electrum JSON-RPC protocol, with extended transaction information (previous outputs, spending transactions, script asm and more).

  • Extended indexes and database storage for improved performance under high load:

    • A full transaction store mapping txids to raw transactions is kept in the database under the prefix t. This takes up ~200GB of extra storage.
    • A map of blockhash to txids is kept in the database under the prefix X.
    • Block stats metadata (number of transactions, size and weight) is kept in the database under the prefix M.
    • The index with T prefix mapping txids to block heights now also includes the block hash. This allows for quick reorg-aware transaction confirmation status lookups, by verifying the current block at the recorded height still matches the recorded block hash.

    With these new indexes, bitcoind is no longer queried to serve user requests and is only polled periodically for new blocks and for syncing the mempool.

  • Support for Liquid and other Elements-based networks, including CT, peg-in/out and multi-asset. (requires enabling the liquid feature flag using --features liquid)

CLI options

In addition to electrs's original configuration options, a few new options are also available:

  • --http-addr <addr:port> - HTTP server address/port to listen on (default: 127.0.0.1:3000).
  • --disable-prevout - disable attaching previous output information to inputs. This significantly reduces the amount of transaction lookups (and IO/CPU/memory usage), at the cost of not knowing inputs amounts, their previous script/address, and the transaction fee.
  • --parent-network <network> - the parent network this chain is pegged to (Elements/Liquid only).
  • --cors <origins> - origins allowed to make cross-site request (optional, defaults to none).

See $ cargo run --release --bin electrs -- --help for the full list of options.

License

MIT

electrs's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.