Duniter squid🔗
Duniter squid is an indexer for Duniter v2 based on the subsquid framework.
- git repository https://git.duniter.org/nodes/duniter-squid
Install duniter-squid🔗
Requirements🔗
You need an archive node running on the same network. In the following, we will assume this archive node is available in the duniter_default network with the url ws://duniter-archive:9944.
Docker compose🔗
The following docker-compose.yml allows you to start a duniter-squid node. Please look carefully at the # <--- comments. To see the name of the network of your archive node, look at docker network ls. This example compose comes from the one on the repo.
services:
# squid processor eating data from duniter archive (RPC_ENDPOINT) and putting them in db
processor:
image: duniter/squid-app-g1:0.5.11
depends_on:
db:
condition: service_healthy
healthcheck:
test: ["CMD-SHELL", "pgrep -f 'lib/main.js'"]
interval: 5s
timeout: 2s
retries: 3
environment:
- DB_NAME=${DB_NAME}
- DB_PORT=5432
- DB_HOST=db
- DB_PASS=${DB_PASSWORD}
- RPC_ENDPOINT=${RPC_ENDPOINT}
command: ["sqd", "process:prod"]
networks:
- default # <--- allows the processor to connect to the postgres database
- duniter # <--- allows the processor to connect to the duniter archive node
# postgres database with LDS support for GraphQL live subscriptions
db:
image: duniter/squid-postgres-g1:0.5.11
volumes:
- postgres-data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
environment:
POSTGRES_DB: ${DB_NAME}
POSTGRES_PASSWORD: ${DB_PASSWORD}
POSTGRES_USER: postgres
POSTGRES_INITDB_ARGS: "--auth-host=md5"
LIVE_THROTTLE: 500
LD_WAIT: 200
command: [
"postgres",
"-c", "wal_level=logical",
"-c", "max_replication_slots=4",
"-c", "max_wal_senders=4",
"-c", "log_min_messages=FATAL",
"-c", "log_replication_commands=off",
"-c", "log_statement=none",
"-c", "log_min_duration_statement=1000"
]
# PostGraphile GraphQL server
server:
image: duniter/squid-graphile-g1:0.5.11
depends_on:
processor:
condition: service_healthy
restart: always
ports:
- "${GRAPHQL_LISTEN_PORT:-8080}:5678"
environment:
DATABASE_URL: postgres://postgres:${DB_PASSWORD}@db:5432/${DB_NAME}
NODE_ENV: production
PORT: 5678
DB_HOST: db
DB_PORT: 5432
DB_NAME: ${DB_NAME}
DB_PASSWORD: ${DB_PASSWORD}
volumes:
postgres-data:
networks:
default:
driver: bridge
duniter:
name: duniter-g1-archive_default # <--- your network name might vary depending on your config / folder name
external: true
And use this example environment file (from .env.example):
# postgres
DB_NAME=squid
DB_PASSWORD=postgres
# graphile
GRAPHQL_LISTEN_PORT=8080
# Duniter RPC endpoint depending on your service name
RPC_ENDPOINT=ws://duniter-archive:9944
When you are ready, run the compose with:
docker compose down -v && # <--- if you want to erase previously existing data \
docker compose up -d && # <--- to start the compose in detached mode \
docker compose logs -f # <--- to see the logs and follow themNginx config🔗
Example nginx config:
server {
listen 443 ssl;
listen [::]:443 ssl;
ssl_certificate /etc/letsencrypt/live/YOUR_DOMAIN/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/YOUR_DOMAIN/privkey.pem;
server_name YOUR_DOMAIN;
access_log /var/log/nginx/YOUR_DOMAIN_access.log;
error_log /var/log/nginx/YOUR_DOMAIN_error.log;
location / {
add_header X-Robots-Tag "noindex";
proxy_pass http://localhost:8080;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
}
}Use duniter-squid🔗
Go on your duniter-squid url https://squid.g1.coinduf.eu/graphiql for example) and make your requests in the GraphiQL playground. Then use the requests in your client.
Announce your endpoint🔗
If you want other people to use your endpoint, do not forget to configure your Duniter node to announce it with DUNITER_PUBLIC_SQUID.