Introducing a new way to review your PRs.

Read the announcement

luke-jr / bfgminer

Modular ASIC/FPGA miner written in C, featuring overclocking, monitoring, fan speed control and remote interface capabilities.

View on GitHub

13 documents · Updated Nov 16, 2026

overview

Knowledge Base updated: 2026-11-16

Knowledge Base Index

1. Orientation

BFGMiner is a modular cryptocurrency miner focused on coordinating pool work, hashing algorithms, device I/O, and many CPU/GPU/FPGA/ASIC mining backends. The highest-level flow is: acquire work from pools or proxies, dispatch it to mining devices, collect nonces/shares, and expose runtime state through the API/HTTP interfaces.

Main parts:

  • Core runtime: process lifecycle, global miner state, scheduling, utilities, and logging.
  • Work and pool protocols: getwork, Stratum, proxy, block-template helpers, and share submission.
  • Device and I/O layer: hardware discovery plus USB/HID/FTDI/PCI/SPI/VCOM backends.
  • Mining implementations: CPU, OpenCL GPU, FPGA/JTAG/ZTEX, USB sticks, and vendor ASIC drivers.
  • Algorithms and hashing: SHA256d, scrypt, keccak, nonce scanning, and optimized CPU paths.
  • Operator interfaces: RPC/API, embedded HTTP server, example clients, build/configuration, packaging, and deployment files.

Critical state is mostly in process memory: miner/device/pool/thread state lives in the C runtime structures, hardware state lives behind low-level device handles, and pool work/results flow over network protocols. There is no database, object store, queue service, or persistent application store in this repository.

2. Architecture diagrams

flowchart TD
  subgraph Runtime
    Core[miner.c / miner.h]
    Util[util + logging]
    API[api.c + httpsrv.c]
  end

  subgraph WorkSources
    Getwork[driver-getwork.c]
    Stratum[driver-stratum.c]
    Proxy[driver-proxy.c]
    BlkMaker[libblkmaker / libbase58]
  end

  subgraph Compute
    Algorithms[malgo + sha256 + findnonce]
    CPU[driver-cpu]
    OpenCL[driver-opencl + ocl + kernels]
  end

  subgraph Hardware
    DeviceAPI[deviceapi + lowlevel]
    FPGA[FPGA / JTAG / ZTEX]
    USB[USB stick + BitFury drivers]
    ASIC[Avalon / Bitmain / vendor ASICs]
  end

  subgraph Ops
    Build[Autotools + packaging]
    Docs[README and platform docs]
  end

  Build --> Core
  Docs --> Build
  Core --> WorkSources
  WorkSources --> Core
  Core --> Algorithms
  Algorithms --> CPU
  Algorithms --> OpenCL
  Core --> DeviceAPI
  DeviceAPI --> FPGA
  DeviceAPI --> USB
  DeviceAPI --> ASIC
  Core --> API
flowchart LR
  Pool[Pool / proxy] --> Protocols[getwork / Stratum / proxy]
  Protocols --> Work[internal work units]
  Work --> Core[miner scheduler]
  Core --> Device[CPU / GPU / FPGA / ASIC driver]
  Device --> Hash[algorithm / nonce scan]
  Hash --> Result[nonce or share result]
  Result --> Core
  Core --> Protocols
  Protocols --> Pool
flowchart TD
  User[RPC or HTTP client] --> HTTP[httpsrv.c]
  HTTP --> API[api.c command handling]
  API --> MinerState[miner runtime state]
  API --> DeviceState[device and driver stats]
  API --> PoolState[pool/work state]
  API --> Response[JSON / API response]

3. Glossary

  • BFGMiner: this repository's modular mining daemon and hardware-driver host.
  • Stratum: pool protocol implemented by driver-stratum.c for streaming mining jobs and submitting shares.
  • getwork: legacy pool-work protocol implemented by driver-getwork.c.
  • ADL: AMD Display Library headers/integration under ADL/** and adl.* for GPU monitoring/control.
  • ZTEX: FPGA board support implemented by driver-ztex.c and libztex.*.

4. Codebase-wide invariants

5. Routing table