Coder Social home page Coder Social logo

simonfuture2 / blockchain-etl Goto Github PK

View Code? Open in Web Editor NEW

This project forked from helium/blockchain-etl

0.0 0.0 0.0 3.08 MB

Blockchain follower that follows and stores the Helium blockchain

License: Apache License 2.0

Makefile 0.54% Erlang 73.42% Shell 1.37% PLpgSQL 24.00% Dockerfile 0.67%

blockchain-etl's Introduction

blockchain-etl

Build status

This is an Erlang application to follow the Helium blockchain and store it in a Postgres database. This ingest service tracks all blocks as they're addded to the blockchain by running a full node and listening for new block events.

Dependencies

To run blockchain-etl, you will need:

  • erlang 22 -- newer versions will not work
  • rust -- we recommend using rustup
  • postgresql + postgis

Optionally you can geocode locations using the Google Maps Geocoding API. Register an API key and update GOOGLE_MAPS_API_KEY=... in your .env.dev file

Installing Erlang 22 on Ubuntu

wget https://packages.erlang-solutions.com/erlang-solutions_2.0_all.deb
sudo dpkg -i erlang-solutions_2.0_all.deb
sudo apt-get update
sudo apt install esl-erlang=1:22.3.4.1-1 cmake libsodium-dev libssl-dev build-essential

Developer Usage

  • Clone this repository

  • Create .env file by copying .env.template and editing it to reflect your postgres and other keys and credentials

    Note: In order for resets to work the postgres user specified in the .env file needs to exist and have CREATEDB permissions.

  • Run make release in the top level folder

  • Run make reset to initialize the database and reset the ledger. You will need to run a make reset every time the release notes indicate to do so. This should be very rare. .

    Running a make reset will keep the existing downloaded blocks but replay the ledger so the application can re-play the blocks into the database. Again, only do this when indicated in the release notes since a replay can take a long time.

  • Run make start to start the application. Logs will be at _build/dev/rel/blockchain_etl/log/*.

Once started the application will start syncing the blockchain and loading blocks into the attached database.

You can change the release target (and .env file) using the PROFILE environment variable, which defaults to dev. i.e.:

make start -e PROFILE=testnet

Note

You may see an error similar to the following during initial sync:

{error,"IO error: While open a file for appending: data/blockchain.db/020311.sst: Too many open files"}

Check this Superuser answer for a workaround on macOS and here for some instructions on various Linux distributions.

WARNING

Schema changes will happen in this repo as we flesh out the corresponding APIs. A schema change may require a make reset to reset the database and associated blockchain ledger. On a reset the blockchain store itself is not affected but the ledger is replayed which allows the application to reload the database.

NOTE: Please refer to the release notes for each release. Unless otherwise indicated you should not do a make reset

Using Docker

Building the Docker Image

docker build -t helium/etl .

Running the Migrations

Be sure to replace with your DATABASE_URL below.

docker run -e DATABASE_URL=postgresql://user:[email protected]:5432/helium_blockchain helium/etl migrations reset

Running the Docker Container

docker run -d --init \
--publish 2154:2154/tcp \
--name etl \
--mount type=bind,source=$HOME/etl_data,target=/var/data \
-e DATABASE_URL=postgresql://user:[email protected]:5432/helium_blockchain \
helium/etl

Updating Docker

Navigate to your copy of the blockchain-etl repository.

cd /path/to/blockchain-etl

Stop the ETL.

docker exec etl blockchain_etl stop

Stop the Docker container.

docker stop etl

Remove the existing Docker container.

docker rm etl

Update the repository.

git pull

Rebuild the Docker image.

docker build -t helium/etl .

Run the updated Docker container.

docker run -d --init \
--publish 2154:2154/tcp \
--name etl \
--mount type=bind,source=/path/to/etl_data,target=/var/data \
-e DATABASE_URL=postgresql://user:[email protected]:5432/helium_blockchain \
helium/etl

Run the migrations.

docker exec etl blockchain_etl migrations run

Start the ETL.

docker exec etl blockchain_etl start

Log the ETL output.

tail -f /path/to/etl_data/log/console.log

blockchain-etl's People

Contributors

abhay avatar evanmcc avatar jadeallenx avatar jamiew avatar knightar avatar madninja avatar nickhough avatar nmharmon8 avatar rawrmaan avatar vagabond avatar vihu 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.