diff options
| author | Bitflash-sh <btf01@proton.me> | 2026-07-24 11:18:11 -0300 |
|---|---|---|
| committer | Bitflash-sh <btf01@proton.me> | 2026-07-24 11:18:11 -0300 |
| commit | 51d617e70f90a972185917ea0096c1ecef2bfa8b (patch) | |
| tree | 9fbbcd867de9de9d0776afdd02f594ba312c46eb /src/randomx_pow.h | |
Bitflash: fair-launch release
Satoshi's bitcoin-0.1.0 reborn with RandomX CPU proof of work, anonymous .btf
addressing over Nostr with CGNAT rendezvous, automatic peer discovery, a
headless Linux node, and Windows GUI wallet. Fair launch, no premine, 21M cap.
Diffstat (limited to 'src/randomx_pow.h')
| -rw-r--r-- | src/randomx_pow.h | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/randomx_pow.h b/src/randomx_pow.h new file mode 100644 index 0000000..0027571 --- /dev/null +++ b/src/randomx_pow.h | |||
| @@ -0,0 +1,44 @@ | |||
| 1 | // Copyright (c) 2026 Bitflash developers | ||
| 2 | // Distributed under the MIT/X11 software license. | ||
| 3 | // | ||
| 4 | // Memory-hard Proof of Work (CPU + RAM) via RandomX -- replaces SHA-256d as | ||
| 5 | // the PoW algorithm. The block IDENTITY hash stays SHA-256d (GetHash), | ||
| 6 | // preserving all indexing; what changes is the PROOF-OF-WORK hash | ||
| 7 | // (GetPoWHash), computed with RandomX. | ||
| 8 | // | ||
| 9 | // Modes: | ||
| 10 | // - Verification (all nodes): 256 MB cache, "light" VM. Cheap. | ||
| 11 | // - Mining (optional, fast): ~2 GB dataset, "full" VMs. Fast. | ||
| 12 | // GPUs and ASICs are neutralized by RandomX's memory cost/latency. | ||
| 13 | |||
| 14 | #ifndef BITFLASH_RANDOMX_POW_H | ||
| 15 | #define BITFLASH_RANDOMX_POW_H | ||
| 16 | |||
| 17 | // uint256 comes from uint256.h, already included by headers.h before this file. | ||
| 18 | |||
| 19 | // Initialize the cache (256 MB) and the verification VM. Call once at startup. | ||
| 20 | // Returns false if allocation fails. | ||
| 21 | bool RandomXInit(); | ||
| 22 | |||
| 23 | // Allocate and initialize the ~2 GB dataset for fast mining (fast mode), | ||
| 24 | // using nThreads to speed it up. Idempotent. Returns false on failure (the | ||
| 25 | // miner then falls back to light mode automatically). | ||
| 26 | bool RandomXInitDataset(int nThreads); | ||
| 27 | |||
| 28 | // PoW hash of an 80-byte header, using the verification VM (thread-safe, | ||
| 29 | // guarded by a critical section). | ||
| 30 | uint256 RandomXPoWHash(const void* pHeader, size_t nSize); | ||
| 31 | |||
| 32 | // Create a VM for a mining thread (own VM, not shared). Uses the dataset | ||
| 33 | // (fast) if available, otherwise the cache (light). Release with | ||
| 34 | // RandomXDestroyMinerVM. Returns NULL on failure. | ||
| 35 | void* RandomXCreateMinerVM(); | ||
| 36 | void RandomXDestroyMinerVM(void* vm); | ||
| 37 | |||
| 38 | // Compute a PoW hash on an owned mining VM (not guarded). | ||
| 39 | uint256 RandomXHashWithVM(void* vm, const void* pHeader, size_t nSize); | ||
| 40 | |||
| 41 | // True when the 2 GB dataset is ready (fast mode active). | ||
| 42 | bool RandomXFastReady(); | ||
| 43 | |||
| 44 | #endif | ||