Skip to content

Commit 89187bf

Browse files
Added new mining methods (#545)
* Added new mining methods Signed-off-by: Madeline Murray <[email protected]> * lint Signed-off-by: Madeline Murray <[email protected]> Co-authored-by: Madeline Murray <[email protected]>
1 parent 4b4d5c3 commit 89187bf

File tree

3 files changed

+127
-3
lines changed

3 files changed

+127
-3
lines changed

docs/HowTo/Configure/Configure-Mining.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ The JSON-RPC API methods for mining are:
5858
* [`miner_stop`](../../Reference/API-Methods.md#miner_stop) to stop mining.
5959
* [`eth_mining`](../../Reference/API-Methods.md#eth_mining) to determine whether the client is
6060
actively mining new blocks.
61+
* [`eth_getMinerDataByBlockHash`](../../Reference/API-Methods.md#eth_getminerdatabyblockhash) and
62+
[`eth_getMinerDataByBlockNumber`](../../Reference/API-Methods.md#eth_getminerdatabyblocknumber) to
63+
get the miner data for a specified block.
6164
* [`eth_hashrate`](../../Reference/API-Methods.md#eth_hashrate) to get the number of hashes per
6265
second with which the node is mining. Not supported for GPU mining.
6366
* [`eth_getWork`](../../Reference/API-Methods.md#eth_getwork) to get the hash of the current block,

docs/Reference/API-Methods.md

Lines changed: 107 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -524,10 +524,10 @@ None
524524

525525
!!! note
526526

527-
For almost all networks network ID and chain ID are the same.
528-
527+
For almost all networks network ID and chain ID are the same.
528+
529529
The only networks in the table above with different network and chain IDs are
530-
Classic with a chain ID of `61` and Mordor with a chain ID of `63`.
530+
Classic with a chain ID of `61` and Mordor with a chain ID of `63`.
531531

532532
!!! example
533533

@@ -1280,6 +1280,110 @@ Returns the account balance of the specified address.
12801280
}
12811281
```
12821282

1283+
### eth_getMinerDataByBlockHash
1284+
1285+
Returns miner data for the specified block.
1286+
1287+
#### Parameters
1288+
1289+
`data` - 32 byte block hash.
1290+
1291+
#### Returns
1292+
1293+
`result`: `object` - [Miner data](API-Objects.md#miner-data-object).
1294+
1295+
!!! example
1296+
1297+
=== "curl HTTP"
1298+
1299+
```bash
1300+
curl -X POST --data '{"jsonrpc":"2.0","method": "eth_getMinerDataByBlockHash","params": ["0xbf137c3a7a1ebdfac21252765e5d7f40d115c2757e4a4abee929be88c624fdb7"],"id": 1}' http://127.0.0.1:8545
1301+
```
1302+
1303+
=== "wscat WS"
1304+
1305+
```bash
1306+
{"jsonrpc":"2.0","method": "eth_getMinerDataByBlockHash","params": ["0xbf137c3a7a1ebdfac21252765e5d7f40d115c2757e4a4abee929be88c624fdb7"],"id": 1}
1307+
```
1308+
1309+
=== "JSON result"
1310+
1311+
```json
1312+
{
1313+
"jsonrpc": "2.0",
1314+
"id": 1,
1315+
"result": {
1316+
"netBlockReward": "0x47c6f3739f3da800",
1317+
"staticBlockReward": "0x4563918244f40000",
1318+
"transactionFee": "0x38456548220800",
1319+
"uncleInclusionReward": "0x22b1c8c1227a000",
1320+
"uncleRewards": [
1321+
{
1322+
"hash": "0x2422d43b4f72e19faf4368949a804494f67559405046b39c6d45b1bd53044974",
1323+
"coinbase": "0x0c062b329265c965deef1eede55183b3acb8f611"
1324+
}
1325+
],
1326+
"coinbase": "0xb42b6c4a95406c78ff892d270ad20b22642e102d",
1327+
"extraData": "0xd583010502846765746885676f312e37856c696e7578",
1328+
"difficulty": "0x7348c20",
1329+
"totalDifficulty": "0xa57bcfdd96"
1330+
}
1331+
}
1332+
```
1333+
1334+
### eth_getMinerDataByBlockNumber
1335+
1336+
Returns miner data for the specified block.
1337+
1338+
#### Parameters
1339+
1340+
`quantity|tag` - Integer representing a block number or one of the string tags `latest`,
1341+
`earliest`, or `pending`, as described in
1342+
[Block Parameter](../HowTo/Interact/APIs/Using-JSON-RPC-API.md#block-parameter).
1343+
1344+
#### Returns
1345+
1346+
`result`: `object` - [Miner data](API-Objects.md#miner-data-object).
1347+
1348+
!!! example
1349+
1350+
=== "curl HTTP"
1351+
1352+
```bash
1353+
curl -X POST --data '{"jsonrpc":"2.0","method": "eth_getMinerDataByBlockNumber","params": ["0x7689D2"],"id": 1}' http://127.0.0.1:8545
1354+
```
1355+
1356+
=== "wscat WS"
1357+
1358+
```bash
1359+
{"jsonrpc":"2.0","method": "eth_getMinerDataByBlockNumber","params": ["0x7689D2"],"id": 1}
1360+
```
1361+
1362+
=== "JSON result"
1363+
1364+
```json
1365+
{
1366+
"jsonrpc": "2.0",
1367+
"id": 1,
1368+
"result": {
1369+
"netBlockReward": "0x47c6f3739f3da800",
1370+
"staticBlockReward": "0x4563918244f40000",
1371+
"transactionFee": "0x38456548220800",
1372+
"uncleInclusionReward": "0x22b1c8c1227a000",
1373+
"uncleRewards": [
1374+
{
1375+
"hash": "0x2422d43b4f72e19faf4368949a804494f67559405046b39c6d45b1bd53044974",
1376+
"coinbase": "0x0c062b329265c965deef1eede55183b3acb8f611"
1377+
}
1378+
],
1379+
"coinbase": "0xb42b6c4a95406c78ff892d270ad20b22642e102d",
1380+
"extraData": "0xd583010502846765746885676f312e37856c696e7578",
1381+
"difficulty": "0x7348c20",
1382+
"totalDifficulty": "0xa57bcfdd96"
1383+
}
1384+
}
1385+
```
1386+
12831387
### eth_getProof
12841388

12851389
Returns the account and storage values of the specified account, including the merkle proof.

docs/Reference/API-Objects.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,23 @@ Returned by [`eth_getFilterChanges`](API-Methods.md#eth_getfilterchanges) and [`
7070
| **data** | Data | Non-indexed arguments of the log. |
7171
| **topics** | Array of Data, 32&nbsp;bytes each | [Event signature hash](../Concepts/Events-and-Logs.md#event-signature-hash) and 0 to 3 [indexed log arguments](../Concepts/Events-and-Logs.md#event-parameters). |
7272

73+
## Miner data object
74+
75+
Returned by [`eth_getMinerDataByBlockHash`](API-Methods.md#eth_getminerdatabyblockhash) and
76+
[`eth_getMinerDataByBlockNumber`](API-Methods.md#eth_getminerdatabyblocknumber).
77+
78+
| Key | Type | Value |
79+
|--------------------------|-:- :-----------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
80+
| **netBlockReward** | Quantity, Integer | The net block reward, in Wei, is `staticBlockReward + transactionFee + uncleInclusionReward`. |
81+
| **staticBlockReward** | Quantity, Integer | The static block reward, in Wei, is preset on a hard fork. |
82+
| **transactionFee** | Quantity, Integer | The transaction fee, in Wei, is `sum of upfront cost - refund amount for all transactions`. |
83+
| **uncleInclusionReward** | Quantity, Integer | The uncle inclusion reward, in Wei, is `static block reward * number of ommers/32`. |
84+
| **uncleRewards** | Map | Map of uncle block hashes and uncle miner coinbase addresses. |
85+
| **coinbase** | Data, 20&nbsp;bytes | Coinbase address. |
86+
| **extraData** | Data | Extra data field for this block. The first 32 bytes is vanity data you can set using the [`--miner-extra-data`](../Reference/CLI/CLI-Syntax.md#miner-extra-data) command line option. |
87+
| **difficulty** | Quantity, Integer | Difficulty of this block. |
88+
| **totalDifficulty** | Quantity, Integer | Total difficulty of the chain until this block. |
89+
7390
## Pending transaction object
7491

7592
Returned by [`txpool_besuPendingTransactions`](API-Methods.md#txpool_besupendingtransactions).

0 commit comments

Comments
 (0)