<ol>
<li><p>Look at <a href="http://www.jsonrpc.org/specification" rel="nofollow">http://www.jsonrpc.org/specification</a>: "An identifier established by the Client that MUST contain a String, Number, or NULL value if included. If it is not included it is assumed to be a notification. The value SHOULD normally not be Null [1] and Numbers SHOULD NOT contain fractional parts [2]." To put it simply, it is really just an identifier for a message.</p></li>
<li><p><a href="https://en.bitcoin.it/wiki/Block_hashing_algorithm" rel="nofollow">https://en.bitcoin.it/wiki/Block_hashing_algorithm</a></p></li>
<li><p>To put it simply, midstate is just the hashing done on the first half. We need the hash done on the whole data, but since the first part of the data doesn't change, we can just calculate it so that we don't have to perform full hashing everytime.</p></li>
<li><p>The target specifies the difficulty. Only a hash that is smaller than the target is accepted. In other words, you can also say that the target specifies the number of trailing zeroes required in the hash.</p></li>
<li><p><a href="https://en.bitcoin.it/wiki/Getwork" rel="nofollow">https://en.bitcoin.it/wiki/Getwork</a></p></li>
</ol>

CC BY-SA 3.0
2013-05-28T01:26:42.487Z
2013-05-28T01:26:42.487Z
Radiance Wei Qi Ong
<p>Request:</p>

<pre><code>POST / HTTP/1.1
Host: de.btcguild.com:8332
Accept: */*
Accept-Encoding: deflate, gzip
Content-type: application/json
X-Mining-Extensions: longpoll midstate rollntime submitold
Content-Length: 44
User-Agent: bfgminer 2.99.1

{"method": "getwork", "params": [], "id":0}
</code></pre>

<p>Response:</p>

<pre><code>HTTP/1.1 200 OK
Server: nginx/0.7.65
Date: Sat, 13 Apr 2013 21:55:23 GMT
Content-Type: application/json;charset=ISO-8859-1
Connection: keep-alive
X-Long-Polling: /LP/
X-Blocknum: 105632
Content-Length: 607

{
"error": null,
"id": 0,
"result": {
"data": "00000002df54a70cd769d78b9605c0a6574638db799e86bdd1183cfc000001c2000000009e7ed0ae4ccdb1dbf283f4ab608791f21b1a5f437f405f4f9ba0bb3b693506a95169d43c1a022fbe00000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000080020000",
"hash1": "00000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000010000",
"midstate": "24a747c3d16eadbc1481bd342b5558b2e235301c11353faf4bc25a384102c9c9",
"target": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000"
}
}
</code></pre>

<ol>
<li>In the request/response what does <code>id</code> do?</li>
<li>In the response what is data and how is it generated?</li>
<li>What is midstate?</li>
<li>How does target work?</li>
<li>In the request what are these <code>X-Mining-Extensions: longpoll midstate rollntime submitold</code> parameters for?</li>
</ol>

<mining-pools><json-rpc><protocol><getwork><http>
Please explain getwork
Mike Hunt
# Please explain getwork

(Asked by: username_0 on 2013-04-13)

Request:

```
POST / HTTP/1.1
Host: de.btcguild.com:8332
Accept: */*
Accept-Encoding: deflate, gzip
Content-type: application/json
X-Mining-Extensions: longpoll midstate rollntime submitold
Content-Length: 44
User-Agent: bfgminer 2.99.1

{"method": "getwork", "params": [], "id":0}

```

Response:

```
HTTP/1.1 200 OK
Server: nginx/0.7.65
Date: Sat, 13 Apr 2013 21:55:23 GMT
Content-Type: application/json;charset=ISO-8859-1
Connection: keep-alive
X-Long-Polling: /LP/
X-Blocknum: 105632
Content-Length: 607

{
"error": null,
"id": 0,
"result": {
"data": "00000002df54a70cd769d78b9605c0a6574638db799e86bdd1183cfc000001c2000000009e7ed0ae4ccdb1dbf283f4ab608791f21b1a5f437f405f4f9ba0bb3b693506a95169d43c1a022fbe00000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000080020000",
"hash1": "00000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000010000",
"midstate": "24a747c3d16eadbc1481bd342b5558b2e235301c11353faf4bc25a384102c9c9",
"target": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000"
}
}

```

1. In the request/response what does `id` do?
2. In the response what is data and how is it generated?
3. What is midstate?
4. How does target work?
5. In the request what are these `X-Mining-Extensions: longpoll midstate rollntime submitold` parameters for?

**Tags:** mining-pools, json-rpc, protocol, getwork, http


---

## 1 answers

### Answer by username_1 on 2013-05-28. Score: 1

1. Look at <http://www.jsonrpc.org/specification>: "An identifier established by the Client that MUST contain a String, Number, or NULL value if included. If it is not included it is assumed to be a notification. The value SHOULD normally not be Null [1] and Numbers SHOULD NOT contain fractional parts [2]." To put it simply, it is really just an identifier for a message.
2. <https://en.bitcoin.it/wiki/Block_hashing_algorithm>
3. To put it simply, midstate is just the hashing done on the first half. We need the hash done on the whole data, but since the first part of the data doesn't change, we can just calculate it so that we don't have to perform full hashing everytime.
4. The target specifies the difficulty. Only a hash that is smaller than the target is accepted. In other words, you can also say that the target specifies the number of trailing zeroes required in the hash.
5. <https://en.bitcoin.it/wiki/Getwork>


---

