How ocean-xyz/datum_gateway works
Main Components
• External Systems:
• Bitcoin Node: the external full node (recommended Bitcoin Knots) that provides block templates via RPC and notifies the gateway via blocknotify.
• Mining Hardware: the miners communicating through the Stratum v1 protocol.
• Mining Pool: uses the DATUM protocol for coordination, generation transaction payout splits, and work validation.
• Core DATUM Gateway Application:
• Gateway Core: responsible for retrieving block templates (using GBT mechanisms) from the Bitcoin node.
• Stratum Interface: handles communication with mining hardware, including Stratum v1 version rolling (ASICBoost) to distribute work.
• DATUM Protocol Module: manages encrypted communication and protocol operations with the pool.
• Utility & Support Modules: these include components like:
• datum_api – likely to encapsulate RPC calls and core interface functions,
• datum_conf – handling configurations,
• datum_logger – for logging system events,
• datum_queue, datum_sockets – managing data queues and network communication,
• Additional modules for block template construction (datum_blocktemplates, datum_submitblock) and protocol handling (datum_jsonrpc, datum_stratum and datum_stratum_dupes).
• Infrastructure and Build/Deployment Components:
• Build System: The CMakeLists.txt and cmake scripts, which coordinate the build with various CMake modules (e.g., EmbedResources, GenerateBuildInfo, VerifyExample).
• Packaging: The debian directory suggests packaging and distribution aspects.
• Continuous Integration: .github/workflows for automated builds.
• Web Interface: The www folder provides static HTML/CSS/JS files for configuration portals or a dashboard.
Relationships and Data Flow
• The Bitcoin Node provides block templates (via RPC with GBT) and sends block change notifications (using blocknotify) to the gateway.
• The Gateway Core uses this information to construct valid work for mining hardware.
• The Stratum Interface exposes work to mining hardware, handling incoming share submissions and other mining interactions.
• The DATUM Protocol Module manages communication with the pool. It both receives instructions (like generation transaction splits) and submits completed blocks. The exchange is secured - encryption and obfuscation are key.
• Internally, various utility modules (API, configuration, logging, etc.) handle cross-cutting concerns for proper functioning and debugging/monitoring.
Architectural Patterns and Technologies
• The project is modular: C source files are split into small, purpose-driven modules (e.g., API handling, configuration, logging). Although simple procedural C code doesn’t impose strict patterns, think of it as a functional modular design.
• The system relies on external libraries (libcurl for web RPC, libjansson for JSON parsing, libmicrohttpd for HTTP endpoints, and libsodium for encryption).
• The web assets (in www/) indicate a minimal dashboard or configuration UI—mark that as a separate presentation layer if needed.
• The build and deployment system is handled through CMake and Debian packaging, which can be noted at the infrastructure level.