Skip to content

Latest commit

 

History

History

commons-worker

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

commons-worker

CPU proof‑of‑work (PoW) implementation. Multiplatform (JVM/JS/Wasm). Useful for local development, tests, and environments without OpenCL.

Features:

  • AttoWorker.cpu() factory (platform default parallelism)
  • AttoWorker.cpu(parallelism: UShort) to tune threads on JVM/JS
  • High‑level helpers: work(block) and work(network, timestamp, target)

Installation

Gradle:

implementation("cash.atto:commons-worker:<version>")

NPM:

npm install @attocash/commons-core @attocash/commons-worker

Basic usage

val worker = AttoWorker.cpu()

// Work for a block (derives threshold and target internally)
val work = worker.work(block)

// Or explicitly with threshold/target
val threshold = AttoWork.getThreshold(block.network, block.timestamp)
val target = block.getTarget()
val work2 = worker.work(threshold, target)

worker.close()

Tune parallelism (JVM)

val worker = AttoWorker.cpu(parallelism = 8U)

See tests at commons-worker/src/commonTest and integration usages in commons-core tests.