This is a tool for indexing transaction from LikeCoin chain, replacing the slow /txs?...
query endpoint provided by Tendermint and the lite client.
make build
For Docker image, run make build-image
to build and tag the Docker image.
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.
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.
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.
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.
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 ./...
Please refer to examples