# hylmithecoder/learnblockchainwithcuda architecture

> Architecture diagram of the GitHub repository hylmithecoder/learnblockchainwithcuda, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hylmithecoder/learnblockchainwithcuda
- Repository: https://github.com/hylmithecoder/learnblockchainwithcuda

## Overview

This educational CUDA project demonstrates a blockchain workflow and a separate miner↔pool simulation. In the standalone demo, the user runs a benchmark and chain/tamper walkthrough using the hashing, blockchain, and GPU-mining components. In the pool workflow, a miner connects over TCP, authorizes, receives work, mines on the GPU, and submits shares; the pool verifies shares and may advance its chain when a share meets the harder block target. The README documents these capabilities; the sampled source does not include the application implementations, so links involving their internal calls rely on that documentation.

Main entry points: [`src/pool.cu`](https://github.com/hylmithecoder/learnblockchainwithcuda/blob/master/src/pool.cu) (Pool Server), [`src/main.cu`](https://github.com/hylmithecoder/learnblockchainwithcuda/blob/master/src/main.cu) (Blockchain Demo), [`src/miner.cu`](https://github.com/hylmithecoder/learnblockchainwithcuda/blob/master/src/miner.cu) (Miner Client), [`src/sha256.cu`](https://github.com/hylmithecoder/learnblockchainwithcuda/blob/master/src/sha256.cu) (SHA-256)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_core["Blockchain Core"]
  node_sha["SHA-256<br/>[sha256.cu]"]
  node_chain["Block / Chain<br/>[blockchain.cu]"]
  node_cpu_pow["CPU Mining<br/>[blockchain.cu]"]
end

subgraph group_gpu["GPU Mining"]
  node_gpu_engine["GPU Miner<br/>[gpu_miner.cu]"]
  node_cuda_kernels["CUDA Kernels<br/>[gpu_miner.cu]"]
end

subgraph group_pool["Pool Simulation"]
  node_miner["Miner Client<br/>[miner.cu]"]
  node_pool_server["Pool Server<br/>[pool.cu]"]
  node_net["TCP / Line Protocol<br/>[net.h]"]
  node_pool_state["Pool Share / Block State<br/>[pool.cu]"]
end

subgraph group_demo["Standalone Demo"]
  node_demo_app["Blockchain Demo<br/>[main.cu]"]
end

node_user(("User"))

node_user -->|"runs demo"| node_demo_app
node_demo_app -->|"checks hashing"| node_sha
node_demo_app -->|"demonstrates chain"| node_chain
node_demo_app -->|"benchmarks CPU"| node_cpu_pow
node_demo_app -->|"benchmarks GPU"| node_gpu_engine
node_cpu_pow -->|"hashes candidates"| node_sha
node_chain -->|"hashes blocks"| node_sha
node_user -->|"starts pool"| node_pool_server
node_user -->|"starts miner"| node_miner
node_miner -->|"connects / exchanges"| node_net
node_pool_server -->|"listens / exchanges"| node_net
node_miner -->|"submits shares"| node_pool_server
node_pool_server -->|"sends jobs"| node_miner
node_miner -->|"mines job"| node_gpu_engine
node_gpu_engine -->|"launches kernels"| node_cuda_kernels
node_pool_server -->|"verifies shares"| node_pool_state
node_pool_server -->|"checks proof"| node_sha
node_pool_server -->|"advances on block"| node_chain

click node_demo_app "https://github.com/hylmithecoder/learnblockchainwithcuda/blob/master/src/main.cu"
click node_sha "https://github.com/hylmithecoder/learnblockchainwithcuda/blob/master/src/sha256.cu"
click node_chain "https://github.com/hylmithecoder/learnblockchainwithcuda/blob/master/src/blockchain.cu"
click node_cpu_pow "https://github.com/hylmithecoder/learnblockchainwithcuda/blob/master/src/blockchain.cu"
click node_gpu_engine "https://github.com/hylmithecoder/learnblockchainwithcuda/blob/master/src/gpu_miner.cu"
click node_cuda_kernels "https://github.com/hylmithecoder/learnblockchainwithcuda/blob/master/src/gpu_miner.cu"
click node_miner "https://github.com/hylmithecoder/learnblockchainwithcuda/blob/master/src/miner.cu"
click node_pool_server "https://github.com/hylmithecoder/learnblockchainwithcuda/blob/master/src/pool.cu"
click node_net "https://github.com/hylmithecoder/learnblockchainwithcuda/blob/master/include/net.h"
click node_pool_state "https://github.com/hylmithecoder/learnblockchainwithcuda/blob/master/src/pool.cu"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_sha,node_chain,node_cpu_pow,node_user toneBlue
class node_gpu_engine,node_cuda_kernels toneAmber
class node_miner,node_pool_server,node_net,node_pool_state toneMint
class node_demo_app toneRose
```

## Components

### Blockchain Core

- [SHA-256](https://github.com/hylmithecoder/learnblockchainwithcuda/blob/master/src/sha256.cu): `src/sha256.cu`
- [Block / Chain](https://github.com/hylmithecoder/learnblockchainwithcuda/blob/master/src/blockchain.cu): `src/blockchain.cu`
- [CPU Mining](https://github.com/hylmithecoder/learnblockchainwithcuda/blob/master/src/blockchain.cu): `src/blockchain.cu`

### GPU Mining

- [GPU Miner](https://github.com/hylmithecoder/learnblockchainwithcuda/blob/master/src/gpu_miner.cu): `src/gpu_miner.cu`
- [CUDA Kernels](https://github.com/hylmithecoder/learnblockchainwithcuda/blob/master/src/gpu_miner.cu): `src/gpu_miner.cu`

### Pool Simulation

- [Miner Client](https://github.com/hylmithecoder/learnblockchainwithcuda/blob/master/src/miner.cu): `src/miner.cu`
- [Pool Server](https://github.com/hylmithecoder/learnblockchainwithcuda/blob/master/src/pool.cu): `src/pool.cu`
- [TCP / Line Protocol](https://github.com/hylmithecoder/learnblockchainwithcuda/blob/master/include/net.h): `include/net.h`
- [Pool Share / Block State](https://github.com/hylmithecoder/learnblockchainwithcuda/blob/master/src/pool.cu): `src/pool.cu`

### Standalone Demo

- [Blockchain Demo](https://github.com/hylmithecoder/learnblockchainwithcuda/blob/master/src/main.cu): `src/main.cu`

### Other components

- **User**

## Connections

- User → Blockchain Demo: runs demo
- Blockchain Demo → SHA-256: checks hashing
- Blockchain Demo → Block / Chain: demonstrates chain
- Blockchain Demo → CPU Mining: benchmarks CPU
- Blockchain Demo → GPU Miner: benchmarks GPU
- CPU Mining → SHA-256: hashes candidates
- Block / Chain → SHA-256: hashes blocks
- User → Pool Server: starts pool
- User → Miner Client: starts miner
- Miner Client → TCP / Line Protocol: connects / exchanges
- Pool Server → TCP / Line Protocol: listens / exchanges
- Miner Client → Pool Server: submits shares
- Pool Server → Miner Client: sends jobs
- Miner Client → GPU Miner: mines job
- GPU Miner → CUDA Kernels: launches kernels
- Pool Server → Pool Share / Block State: verifies shares
- Pool Server → SHA-256: checks proof
- Pool Server → Block / Chain: advances on block
