How blinkhash/foundation-v1-server works
Project Type & Purpose
• This is a back-end Node.js application (“foundation-server”) that provides:
– A Stratum‐protocol pool server for miners
– Share validation and persistence
– Reward/payment calculation and dispatch
– Statistics collection and HTTP API for monitoring/management
• There’s no built-in front end; a separate client will interact via the API and Stratum.
File Structure
• configs/ – JSON/JS files: main platform settings, pool definitions
• certificates/ – SSL/TLS certs for securing Stratum or API endpoints
• scripts/main/
– server.js: orchestrates startup, exposes HTTP & Stratum services
– stratum.js: Stratum protocol server for miners
– api.js: HTTP REST RPC for operator queries & stats
– database.js: DB connection layer (MySQL/PostgreSQL)
– loader.js: Polls external coin daemons (block height, difficulty)
– builder.js: Constructs new mining jobs, handles job queues
– shares.js: Validates and records miner shares
– payments.js: Calculates payouts, submits transactions to coin daemons
– statistics.js: Aggregates real-time metrics (hashrate, shares, blocks)
– logger.js: Centralized logging
– threads.js & workers.js: Worker thread management for CPU-bound tasks
– utils.js: Shared helpers
• scripts/test/: Unit and integration tests
• package.json: Node.js dependencies (e.g., “stratum-pool,” ORM, worker threads)
Extract Key Architecture Notes from README
• All-in-one, highly scalable, Node.js
• Core features: stratum pool, share processing, payout engine
• Configuration-driven (per-coin configs in “configs/”)
• External docs & configs live in separate repos
• Licensed GPL-2.0
Main Components & Boundaries
A. External Actors/Systems
1. Miners (via TCP Stratum protocol)
2. Coin Daemon(s) (via JSON-RPC over HTTP)
3. Operator/Client UIs (via HTTP REST API)
B. Foundation-Server Core
1. Configuration Loader (reads configs/*, certificates/*)
2. Stratum Server Module (scripts/main/stratum.js)
3. Job Builder Module (builder.js)
4. Share Validator & Persister (shares.js → database)
5. Payment Engine (payments.js → daemon RPC)
6. Blockchain Loader (loader.js → daemon RPC)
7. Statistics Engine (statistics.js → database or in‐