# Mining

## Resources related to mining Gapcoin

### GapMiner posts

Primorial offsets
Apr 19, 2021

Copied across from the Mersenne Forum

Potential CRT improvement
Apr 19, 2021

Copied across from the Mersenne Forum

Creating and using locally-compiled static libgmp and libmpfr libraries for linking with GapMiner
Apr 9, 2021

Technical HOW-TO compile and use optimised-to-CPU GMP and MPFR libraries

The algorithm

The average length of a prime gap with the starting prime $p$, is $log\left(p\right)$, which means that the average prime gap size increases with larger primes. Instead of the pure length, Gapcoin uses the merit of a prime gap, which is the ratio of the gap’s size to the average gap size. Let $p$ be the prime starting a prime gap, then $m = gapsize/log\left(p\right)$ will be the merit of this prime gap.

Also a pseudo random number is calculated from $p$ to provide finer difficulty adjustment. Let $rand\left(p\right)$ be a pseudo-random function with $0 < rand\left(p\right) < 1$. Then, for a prime gap starting at prime $p$ with size $s$, the difficulty will be $s/log\left(p\right) + 2/log\left(p\right) \ast rand\left(p\right)$, where $2/log\left(p\right)$ is the average distance between a gap of size $s$ and $s + 2$ (the next greater gap) in the proximity of $p$.

When it actually comes to mining, there are two additional fields added to the block header, named “shift” and “adder”. We will calculate the prime $p$ as `sha256(block header) ∗ 2^shift + adder`. As an additional criterion, the adder must be smaller than `2^shift` to avoid the PoW being reused.

See “Gapminer parameter list and description of approach” for further details of the mining approach.

### Basic Gapcoin mining with default miner parameter settings

#### Pool mining with getwork

`gapminer -o http://your-pool.club -p 4200 -u user.worker -x password -t [number_of_threads]`

#### Pool mining with stratum (recommended)

`gapminer -o your-pool.club -p 3385 -u user.worker -x password --stratum -t [number_of_threads]`

#### Solo mining

`gapminer -o 127.0.0.1 -p 31397 -u <rpcuser> -x <rpcpassword> -t [number_of_threads]`

### Pool mining

Mining pools

Help document listing the current GapMiner mining pools, signup instructions and parameter settings.

### GapMiner documentation

CPU GapMiner and GPU GapMiner Basics
Introduction

Concise introduction to Gapminer and explanation of the `--shift`, `--sieve-primes` and `--sieve-size` settings common to both GapMiner and the in-wallet miner

CPU GapMiner technical basics

Reference document listing all the Gapminer parameters and giving a basic high-level description of the mathematical strategy adopted by the miner to finding prime gaps

GPU GapMiner technical basics (WiP)

Reference document listing all the GPU Gapminer parameters and giving a basic high-level description of the mathematical strategy adopted by the miner to finding prime gaps

Running GapMiner on a GPU (WiP)

Help document of distilled developer posts on running GapMiner on a GPU - parameter settings and basic advice on performance.

GapMiner performance test reports
Charts of performance on systematically varied settings.

Reference document, plots of relative performance results across a number of mining parameter test settings

CPU GapMiner and Chinese Remainder Theorem mining
Mining at higher shifts with Chinese Remainder Theoren

Basic HOW-TO for mining using the Chinese Remainder Theorem. Full description and examples of the settings for using GapMiner with CRT.

Creating crt files

Advanced HOW-TO with explanation and examples for creating custom “crt” files for optimising CRT mining.

GapMiner settings for creating the standard set of crt files

Settings used by j0nn9 for create the standard set of crt files.

GapMiner settings for creating Wizz’ extended range of crt files

Settings used by Wizz to create the extended set of 22m crt files.

Specific Chinese Remainder Theorem crt files contributed by pdazzl