# PoW and mining

Mazze uses a Proof of Work scheme backed by RandomX hashing. Mining produces a nonce that satisfies a difficulty boundary.

## Proof of Work primitives

* `ProofOfWorkProblem` bundles the block hash, difficulty, boundary, and seed.
* `ProofOfWorkSolution` carries the nonce.
* `PowComputer` computes the PoW hash with RandomX using a cached VM.

The boundary is derived from difficulty; a block is valid when `pow_hash <= boundary`.

## RandomX cache and seed

`PowComputer` uses `RandomXCacheBuilder` to hold RandomX VMs and to swap context when the seed hash changes. This makes per-block hashing fast while still rotating the seed across epochs.

## Difficulty adjustment

`target_difficulty` computes the next target from recent blocks, the configured block generation period, and the adjustment epoch period in `ProofOfWorkConfig`.

## Mining modes

* `CPU` - local worker threads iterate nonces.
* `Stratum` - a job dispatcher hands work to external miners and validates submitted nonces.
* `Disable` - mining is turned off (used for read-only nodes or some dev modes).

## Key source files

* `crates/mazzecore/core/src/pow/mod.rs`
* `crates/mazzecore/core/src/pow/cache.rs`
* `crates/blockgen/src/lib.rs`
* `crates/blockgen/src/miner/stratum.rs`


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.mazze.io/architecture/pow-and-mining.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
