# Local mining activity

`GET /stats/local` · Lithos client API · Statistics · requires the `api_key` header

Source: https://lithosprotocol.org/docs/api/get-local-mining-stats

Cumulative counters from this client's own share validator, solution submitter and
fraud-proof evaluator — local activity and health, not chain facts. A producer is missing
until it publishes its first observation, and each carries its own freshness status,
session id and sequence number.

Counters restart whenever a producer starts a new session, so only compare observations
sharing a `session`. A missing or stopped producer is not zero activity, and reduced share
reporting drops work, so accepted share work is not a full local hashrate. Node-accepted
solutions and fraud transactions are submissions, not chain confirmations.

Fraud observations keep at most 100 recent targets. Once older ones are evicted
`deduplicationComplete` turns false, and a repeat target may then be counted twice.

## Responses

### 200: The latest observation per producer; the map may be empty.

`LocalMiningResponse`

- `enabled` (boolean, required): Whether statistics collection is on at all. Local observations do not need persisted mining history.
- `producers` (object, required): The latest observation per producer. A missing key means that producer has not reported.
  - `shares` (LocalMiningActivityView)
    - `status` (string, required, one of ready, stale, stopped): Freshness of this producer's latest observation. `stopped` is its final snapshot.
    - `observation` (LocalMiningObservation, required)
      - `kind` (string, required, one of shares, solutions, fraud)
      - `session` (string, required): Session id. A new one means the counters reset.
      - `sequence` (integer · int64, required): Snapshot number within the session. It only increases, but can skip values.
      - `startedAt` (integer · int64, required): When the session started, in Unix milliseconds.
      - `observedAt` (integer · int64, required): Snapshot time in Unix milliseconds.
      - `counters` (map<string, string>, required): Cumulative counters for this session, as exact decimal strings. A missing counter means nothing of that kind was seen in the session. **shares** — `accepted`, `acceptedAssignedWork`, `acceptedBelowAdvertised`, `blockCandidates`, `superShares`, `acceptedWithReducedReporting`, and a `rejected<code>` per rejection code seen. Assigned work adds up the expected hashes behind each share that met its job's advertised difficulty. `acceptedBelowAdvertised` counts shares that passed validation but missed that difficulty; they carry no work, and a count that keeps pace with `accepted` means a miner is not using the difficulty it was sent. Candidates and super shares overlap and are both subsets of `accepted`. **solutions** — `nodeAccepted` and `nodeRejectedOrFailed`. **fraud** — `discoveriesWithinSession`, `nodeAcceptedProofsWithinSession` and `discoveryEvictions`. Accepted means the node took the submission, not that the chain confirmed it. 
      - `fraud` (FraudObservation[], required): Recent fraud targets, capped at 100. Always empty for the share and solution producers.
      - `superShareHeights` (integer[]): Heights of the ten highest super shares this session, highest first. Only the share producer fills it.
      - `stopped` (boolean, required): Whether this is the producer's last observation before it stopped.
    - `deduplicationComplete` (boolean, required): False once fraud targets have been evicted, after which a repeat discovery or submission may be counted twice.
  - `solutions` (LocalMiningActivityView)
  - `fraud` (LocalMiningActivityView)

### 403: The api_key header is missing or wrong.

`ApiError`

- `error` (integer, required): Error code
- `reason` (string, required): Error message explaining the reason of the error
- `detail` (string, required): Detailed error description

## Example request

```bash
curl -X GET "http://localhost:9000/stats/local" \
  -H "api_key: $LITHOS_API_KEY"
```

## Example response

```json
{
  "enabled": true,
  "producers": {
    "shares": {
      "status": "ready",
      "observation": {
        "kind": "shares",
        "session": "string",
        "sequence": 0,
        "startedAt": 0,
        "observedAt": 0,
        "counters": {
          "key": "1000000000"
        },
        "fraud": [
          {
            "rollupBlockId": "string",
            "minerHash": "string",
            "proofContractHash": "string",
            "observedAt": 0,
            "transactionId": "string"
          }
        ],
        "superShareHeights": [
          0
        ],
        "stopped": true
      },
      "deduplicationComplete": true
    },
    "solutions": {
      "status": "ready",
      "observation": {
        "kind": "shares",
        "session": "string",
        "sequence": 0,
        "startedAt": 0,
        "observedAt": 0,
        "counters": {
          "key": "1000000000"
        },
        "fraud": [
          {
            "rollupBlockId": "string",
            "minerHash": "string",
            "proofContractHash": "string",
            "observedAt": 0,
            "transactionId": "string"
          }
        ],
        "superShareHeights": [
          0
        ],
        "stopped": true
      },
      "deduplicationComplete": true
    },
    "fraud": {
      "status": "ready",
      "observation": {
        "kind": "shares",
        "session": "string",
        "sequence": 0,
        "startedAt": 0,
        "observedAt": 0,
        "counters": {
          "key": "1000000000"
        },
        "fraud": [
          {
            "rollupBlockId": "string",
            "minerHash": "string",
            "proofContractHash": "string",
            "observedAt": 0,
            "transactionId": "string"
          }
        ],
        "superShareHeights": [
          0
        ],
        "stopped": true
      },
      "deduplicationComplete": true
    }
  }
}
```
