gaga5lala / eth-indexer-practice

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Getting Started

Development Environment

  • PostgreSQL 14.2
  • Go version go1.17.8 darwin/amd64

Start the services

$ docker run --name some-postgres -e POSTGRES_PASSWORD=mysecretpassword -d -p 5432:5432 postgres:14.2-alpine
$ go run ./service/api
$ go run ./service/indexer

Endpoints

http://localhost:8080/blocks
// ex. http://localhost:8080/blocks
http://localhost:8080/blocks/:block_num
// ex. http://localhost:8080/blocks/18002001
http://localhost:8080/transaction/:tx_hash
// ex. http://localhost:8080/transaction/0x0b2d7be2310b674d093723d213eddd6a5a8e729d0d216e63714f56965b421a76

Notes

  • 還沒有處理 graceful shutdown
  • 當 DB table blocks 沒有紀錄的時候,從 #18002001 開始抓取而不是從 #1,是因為前面的區塊大多沒有 transaction
  • 還沒有利用 Makefile 和 Docker 包裝。(在 base-image build go binary,再放到 go-image,開發者只需要安裝 docker 不需要自行安裝 go、postgres 的環境)

About


Languages

Language:Go 100.0%