Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ API_SECURE=false
# Default is "Public-Pool", you can change it to any string it will be removed if it will make the block or coinbase script too big
POOL_IDENTIFIER="Public-Pool"

# Database configuration
# Select 'sqlite' or 'postgres'
DB_TYPE=sqlite
DB_HOST=localhost
DB_PORT=5432
DB_USER=blitzpool
DB_PASSWORD=blitzpool
DB_NAME=blitzpool

# Optional block template refresh interval (ms)
#BLOCK_TEMPLATE_INTERVAL=30000
# Job and template retention time (ms)
Expand All @@ -46,3 +55,6 @@ JOB_RETENTION_MS=90000
TARGET_SHARES_PER_MINUTE=6
# Interval for checking and adjusting miner difficulty (ms)
DIFFICULTY_CHECK_INTERVAL_MS=60000

# Optional: source SQLite path for migrate:pg scripts
#SQLITE_DB_PATH=DB/public-pool.sqlite
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,36 @@ BlitzPool enriches peer information using the free [ip-api.com](https://ip-api.c
- Desired share rate per worker can be tuned with `TARGET_SHARES_PER_MINUTE` (default `6`)
- How often miners are checked for new difficulty can be set via `DIFFICULTY_CHECK_INTERVAL_MS` (default `60000` ms)

## Database Configuration

BlitzPool supports SQLite (default) and PostgreSQL backends. Select the database with the `DB_TYPE` environment variable:

- `DB_TYPE=sqlite` uses a local file-based database and requires no further settings.
- `DB_TYPE=postgres` enables PostgreSQL. Configure connection details with `DB_HOST`, `DB_PORT`, `DB_USER`, `DB_PASSWORD`, and `DB_NAME`. Default credentials in example env files use `blitzpool` for user, password, and database name.

See `.env.example` or `full-setup/blitzpool-example.env` for sample values.

To start BlitzPool with PostgreSQL using Docker Compose, run:

```bash
docker compose -f docker-compose.postgres.yml up
```

To migrate an existing SQLite database to PostgreSQL, ensure the `DB_*` environment variables point to your Postgres instance and run:

```bash
npm run migrate:pg
```

By default the script reads from `DB/public-pool.sqlite` and copies all entities into the configured PostgreSQL database. To
migrate a database created via the `full-setup` scripts, run:

```bash
npm run migrate:pg_fullsetup
```

Alternatively, set `SQLITE_DB_PATH` to the location of your SQLite file before invoking the migration command.

## API

- `GET /api/info/chart?range=1d|1m` – Returns pool hashrate statistics.
Expand Down
41 changes: 41 additions & 0 deletions docker-compose.postgres.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
version: '3.8'

services:
postgres:
image: postgres:17
container_name: postgres
restart: unless-stopped
environment:
- POSTGRES_USER=blitzpool
- POSTGRES_PASSWORD=blitzpool
- POSTGRES_DB=blitzpool
volumes:
- pgdata:/var/lib/postgresql/data

public-pool:
container_name: public-pool
build:
context: .
dockerfile: Dockerfile
restart: unless-stopped
extra_hosts:
- "host.docker.internal:host-gateway"
depends_on:
- postgres
ports:
- "127.0.0.1:${STRATUM_PORT}:${STRATUM_PORT}/tcp"
- "127.0.0.1:${API_PORT}:${API_PORT}/tcp"
volumes:
- "./${NETWORK}-DB:/public-pool/DB"
- "./.env:/public-pool/.env:ro"
environment:
- NODE_ENV=production
- DB_TYPE=postgres
- DB_HOST=postgres
- DB_PORT=5432
- DB_USER=blitzpool
- DB_PASSWORD=blitzpool
- DB_NAME=blitzpool

volumes:
pgdata:
12 changes: 12 additions & 0 deletions full-setup/blitzpool-example.env
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,15 @@ NETWORK=mainnet

API_SECURE=false
POOL_IDENTIFIER="blitzpool"

# Database configuration
# Select 'sqlite' or 'postgres'
DB_TYPE=sqlite
DB_HOST=localhost
DB_PORT=5432
DB_USER=blitzpool
DB_PASSWORD=blitzpool
DB_NAME=blitzpool

# Optional: source SQLite path for migrate:pg scripts
#SQLITE_DB_PATH=./data/mainnet/public-pool/public-pool.sqlite
Loading