# mining-luck

> bitcoin mining luck

Latest version **0.0.1** (published 2019-05-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install mining-luck
pnpm add mining-luck
yarn add mining-luck
bun add mining-luck
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2019-05-12 |
| First published | 2019-05-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 2.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Mark Robson mark.o.robson@gmail.com |
| Maintainers | roppa_uk |

## Links

- npm: https://www.npmjs.com/package/mining-luck
- npm.io page: https://npm.io/package/mining-luck

## Recent versions

- 0.0.1 (latest) — 2019-05-12

## README

# Bitcoin Block Luck calculation

This is a utility for Bitcoin miners/mining pools to calculate the 'luck' of mining a block.

When a block has been mined you need to save when the block was started mined (created) and the mined at (when a hash has been found) timestamps.

First we need to cover constant values:

- hash = 2 pow 32
- PHz per second = 10 pow 15
- block average = hash * PHz per second

To calculate luck you need how long it took to mine the block, your total hashrate, and network difficulty. Eg:

- difficulty = 336899932795 // network difficulty
- hashrate = total hashrate of mined block
- minedTimeSeconds = (minedat - created) in seconds

## luck({ difficulty, hashrate, minedTimeSeconds })

```javascript
console.log(luck({
  difficulty: 336899932795
  hashrate: 154.9, // block hashrate
  minedTimeSeconds: 9172 // how long block took to mine
})) // '102.71'
```

---
_Source: https://npm.io/package/mining-luck · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
