Skip to content

Ethash

Entity Version
Source 1.11.23-unstable/generated-at:2021-04-30T19:24:24+03:00
OpenRPC 1.2.6

ethash_getHashrate

GetHashrate returns the current hashrate for local CPU miner and remote miner.

Params (0)

None

Result

uint64

  • Required: ✓ Yes
1
2
3
4
- description: `Hex representation of the integer`
- pattern: `^0x[a-fA-F0-9]+$`
- title: `integer`
- type: string
1
2
3
4
5
6
7
8
{
    "description": "Hex representation of the integer",
    "pattern": "^0x[a-fA-F0-9]+$",
    "title": "integer",
    "type": [
        "string"
    ]
}

Client Method Invocation Examples

1
curl -X POST -H "Content-Type: application/json" http://localhost:8545 --data '{"jsonrpc": "2.0", "id": 42, "method": "ethash_getHashrate", "params": []}'
1
wscat -c ws://localhost:8546 -x '{"jsonrpc": "2.0", "id": 1, "method": "ethash_getHashrate", "params": []}'
1
ethash.getHashrate();
Source code

1
2
3
func (api *API) GetHashrate() uint64 {
    return uint64(api.ethash.Hashrate())
}// GetHashrate returns the current hashrate for local CPU miner and remote miner.
View on GitHub →


ethash_getWork

GetWork returns a work package for external miner.

The work package consists of 3 strings: result[0] - 32 bytes hex encoded current block header pow-hash result[1] - 32 bytes hex encoded seed hash used for DAG result[2] - 32 bytes hex encoded boundary condition (“target”), 2^256/difficulty result[3] - hex encoded block number

Params (0)

None

Result

num4string [4]string

  • Required: ✓ Yes
1
2
3
4
5
6
7
8
- items: 

        - type: string


- maxItems: `4`
- minItems: `4`
- type: array
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
{
    "items": [
        {
            "type": [
                "string"
            ]
        }
    ],
    "maxItems": 4,
    "minItems": 4,
    "type": [
        "array"
    ]
}

Client Method Invocation Examples

1
curl -X POST -H "Content-Type: application/json" http://localhost:8545 --data '{"jsonrpc": "2.0", "id": 42, "method": "ethash_getWork", "params": []}'
1
wscat -c ws://localhost:8546 -x '{"jsonrpc": "2.0", "id": 1, "method": "ethash_getWork", "params": []}'
1
ethash.getWork();
Source code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
func (api *API) GetWork() ([4]string, error) {
    if api.ethash.remote == nil {
        return [4]string{}, errors.New("not supported")
    }
    var (
        workCh  = make(chan [4]string, 1)
        errc    = make(chan error, 1)
    )
    select {
    case api.ethash.remote.fetchWorkCh <- &sealWork{errc: errc, res: workCh}:
    case <-api.ethash.remote.exitCh:
        return [4]string{}, errEthashStopped
    }
    select {
    case work := <-workCh:
        return work, nil
    case err := <-errc:
        return [4]string{}, err
    }
}// GetWork returns a work package for external miner.
//
// The work package consists of 3 strings:
//   result[0] - 32 bytes hex encoded current block header pow-hash
//   result[1] - 32 bytes hex encoded seed hash used for DAG
//   result[2] - 32 bytes hex encoded boundary condition ("target"), 2^256/difficulty
//   result[3] - hex encoded block number
View on GitHub →


ethash_submitHashRate

SubmitHashrate can be used for remote miners to submit their hash rate. This enables the node to report the combined hash rate of all miners which submit work through this node.

It accepts the miner hash rate and an identifier which must be unique between nodes.

Params (2)

Parameters must be given by position.

1: rate hexutil.Uint64

  • Required: ✓ Yes
1
2
3
4
- description: `Hex representation of a uint64`
- pattern: `^0x([a-fA-F\d])+$`
- title: `uint64`
- type: string
1
2
3
4
5
6
7
8
{
    "description": "Hex representation of a uint64",
    "pattern": "^0x([a-fA-F\\d])+$",
    "title": "uint64",
    "type": [
        "string"
    ]
}

2: id common.Hash

  • Required: ✓ Yes
1
2
3
4
- description: `Hex representation of a Keccak 256 hash`
- pattern: `^0x[a-fA-F\d]{64}$`
- title: `keccak`
- type: string
1
2
3
4
5
6
7
8
{
    "description": "Hex representation of a Keccak 256 hash",
    "pattern": "^0x[a-fA-F\\d]{64}$",
    "title": "keccak",
    "type": [
        "string"
    ]
}

Result

bool

  • Required: ✓ Yes

Client Method Invocation Examples

1
curl -X POST -H "Content-Type: application/json" http://localhost:8545 --data '{"jsonrpc": "2.0", "id": 42, "method": "ethash_submitHashRate", "params": [<rate>, <id>]}'
1
wscat -c ws://localhost:8546 -x '{"jsonrpc": "2.0", "id": 1, "method": "ethash_submitHashRate", "params": [<rate>, <id>]}'
1
ethash.submitHashRate(rate,id);
Source code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
func (api *API) SubmitHashRate(rate hexutil.Uint64, id common.Hash) bool {
    if api.ethash.remote == nil {
        return false
    }
    var done = make(chan struct{}, 1)
    select {
    case api.ethash.remote.submitRateCh <- &hashrate{done: done, rate: uint64(rate), id: id}:
    case <-api.ethash.remote.exitCh:
        return false
    }
    <-done
    return true
}// SubmitHashrate can be used for remote miners to submit their hash rate.
// This enables the node to report the combined hash rate of all miners
// which submit work through this node.
//
// It accepts the miner hash rate and an identifier which must be unique
// between nodes.
View on GitHub →


ethash_submitWork

SubmitWork can be used by external miner to submit their POW solution. It returns an indication if the work was accepted. Note either an invalid solution, a stale work a non-existent work will return false.

Params (3)

Parameters must be given by position.

1: nonce types.BlockNonce

  • Required: ✓ Yes
1
2
3
4
- description: `Hex representation of the integer`
- pattern: `^0x[a-fA-F0-9]+$`
- title: `integer`
- type: string
1
2
3
4
5
6
7
8
{
    "description": "Hex representation of the integer",
    "pattern": "^0x[a-fA-F0-9]+$",
    "title": "integer",
    "type": [
        "string"
    ]
}

2: hash common.Hash

  • Required: ✓ Yes
1
2
3
4
- description: `Hex representation of a Keccak 256 hash`
- pattern: `^0x[a-fA-F\d]{64}$`
- title: `keccak`
- type: string
1
2
3
4
5
6
7
8
{
    "description": "Hex representation of a Keccak 256 hash",
    "pattern": "^0x[a-fA-F\\d]{64}$",
    "title": "keccak",
    "type": [
        "string"
    ]
}

3: digest common.Hash

  • Required: ✓ Yes
1
2
3
4
- description: `Hex representation of a Keccak 256 hash`
- pattern: `^0x[a-fA-F\d]{64}$`
- title: `keccak`
- type: string
1
2
3
4
5
6
7
8
{
    "description": "Hex representation of a Keccak 256 hash",
    "pattern": "^0x[a-fA-F\\d]{64}$",
    "title": "keccak",
    "type": [
        "string"
    ]
}

Result

bool

  • Required: ✓ Yes

Client Method Invocation Examples

1
curl -X POST -H "Content-Type: application/json" http://localhost:8545 --data '{"jsonrpc": "2.0", "id": 42, "method": "ethash_submitWork", "params": [<nonce>, <hash>, <digest>]}'
1
wscat -c ws://localhost:8546 -x '{"jsonrpc": "2.0", "id": 1, "method": "ethash_submitWork", "params": [<nonce>, <hash>, <digest>]}'
1
ethash.submitWork(nonce,hash,digest);
Source code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
func (api *API) SubmitWork(nonce types.BlockNonce, hash, digest common.Hash) bool {
    if api.ethash.remote == nil {
        return false
    }
    var errc = make(chan error, 1)
    select {
    case api.ethash.remote.submitWorkCh <- &mineResult{nonce: nonce, mixDigest: digest, hash: hash, errc: errc}:
    case <-api.ethash.remote.exitCh:
        return false
    }
    err := <-errc
    return err == nil
}// SubmitWork can be used by external miner to submit their POW solution.
// It returns an indication if the work was accepted.
// Note either an invalid solution, a stale work a non-existent work will return false.
View on GitHub →



Last update: 2022-06-28