GithubHelp home page GithubHelp logo

rust-bitcoin-indexer's Introduction

Bitcoin Indexer

An experiment in indexing Bitcoin, in Rust.

Query blocks using JsonRPC, dump them into Postgres. Handle reorg detections.

WIP, Goals:

  • check how much code is realistically necessary
  • check how simple/complex can it be
  • check Rust ecosystem support (rust-bitcoin mostly)
  • check performance and see how much can it be optimized
  • check unkown unknows and own knowledge

Running

Install Rust with https://rustup.rs

Setup Bitcoind full node, with a config similiar to this:

# [core]
# Run in the background as a daemon and accept commands.
daemon=0
txindex=1

# [rpc]
# Accept command line and JSON-RPC commands.
server=1
# Username for JSON-RPC connections
rpcuser=user
# Password for JSON-RPC connections
rpcpassword=password

# [wallet]
# Do not load the wallet and disable wallet RPC calls.
disablewallet=1
walletbroadcast=0

txindex=1 shouldn't be neccessary, and the only important part here is being able to access RPC interface.

Setup Postgresql DB, with a db and user:pass that can access it. Example:

sudo su postgres
export PGPASSWORD=bitcoin-indexer
createuser bitcoin-indexer
createdb bitcoin-indexer bitcoin-indexer

Install diesel with postgresq support to manage db schema (I need to get rid of this):

cargo install diesel_cli --no-default-features --features postgres

Setup .env file with Postgresql settings (URL with password, user, dbname). Example.

DATABASE_URL=postgres://bitcoin-indexer:bitcoin-indexer@localhost/bitcoin-indexer

Create schema:

diesel migration run

If you ever want to wipe the db :

diesel migration redo

Now everything should be ready. Compile and run with:

cargo build --release; \
	and time ./target/release/rust-bitcoin-indexer \
	--rpc-url http://localhost:8332 \
	--rpc-user user --rpc-pass password

rust-bitcoin-indexer's People

Contributors

dpc avatar

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.