Giter Club home page Giter Club logo

likecoin-chain-tx-indexer's Introduction

likecoin-chain-tx-indexer

This is a tool for indexing transaction from LikeCoin chain, replacing the slow /txs?... query endpoint provided by Tendermint and the lite client.

Build

make build

For Docker image, run make build-image to build and tag the Docker image.

Usage

You need a Postgres server as the storage database of indexed transactions.

In the following commands, you can specify the Postgres connection by providing postgres-db, postgres-host, postgres-port, postgres-user, postgres-pwd parameters.

You may refer to docker-compose.yml provided for Docker setup.

import

indexer import \
    --postgres-db "postgres" \
    --postgres-host "localhost" \
    --postgres-port "5432" \
    --postgres-user "postgres" \
    --postgres-pwd "password" \
    --liked-path ".liked"

Import and index the transactions from existing LikeCoin chain data folder.

Note that the node needs to be shutdown before importing, since LevelDB does not allow concurrent access from different processes.

poller

indexer serve poller \
    --postgres-db "postgres" \
    --postgres-host "localhost" \
    --postgres-port "5432" \
    --postgres-user "postgres" \
    --postgres-pwd "password" \
    --lcd-endpoint "http://localhost:1317"

Start poller, which will poll and index new transactions from the lite client into Postgres database.

HTTP server

indexer serve http \
    --postgres-db "postgres" \
    --postgres-host "localhost" \
    --postgres-port "5432" \
    --postgres-user "postgres" \
    --postgres-pwd "password" \
    --lcd-endpoint "http://localhost:1317" \
    --listen-addr ":8997"

Start serving the query endpoints.

For /txs endpoint, the query format is the same as the /txs?... endpoint of the lite client. Example: http://localhost:8997/txs?message.action=send&page=3005&limit=100

Unrecognized endpoints will be forwarded to the lite client.

testing

You may run a testing Postgres database:

docker compose run --rm -p 127.0.0.1:5433:5432 test-db

Then run make test.

Alternatively, provide an empty Postrgres database with environment variables:

DB_NAME=my_pg_db DB_HOST=somewhere DB_PORT=15432 DB_USER=my_pg_user DB_PASS=my_password go test ./...

API Example

Please refer to examples

likecoin-chain-tx-indexer's People

Contributors

nnkken avatar weijun0827 avatar lancatlin avatar williamchong avatar tsai-hsueh-kuan avatar

Watchers

James Cloos 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.