Bitcoin Forum
May 14, 2024, 03:52:43 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Getwork RPC call question  (Read 1943 times)
TierNolan (OP)
Legendary
*
Offline Offline

Activity: 1232
Merit: 1083


View Profile
June 29, 2011, 02:23:27 PM
 #1

How does the RPC getwork system work?

From the wiki:
Quote
[data]     If [data] is not specified, returns formatted hash data to work on:

    * "midstate" : precomputed hash state after hashing the first half of the data
    * "data" : block data
    * "hash1" : formatted hash buffer for second hash
    * "target" : little endian hash target

If [data] is specified, tries to solve the block and returns true if it was successful.

You have solved the block if it is

sha-256(sha-256(data)) < difficulty target

Is block data just the header?

Also, is midstate the sha-256 of the first 76 bytes (to where the nonce starts)?

Presumably, this would allow the miners to save state of their SHA calculation and reset to byte 76 instead of doing the calculations over and over.

When a miner hits the target, how does it send the nonce back?

1LxbG5cKXzTwZg9mjL3gaRE835uNQEteWF
1715658763
Hero Member
*
Offline Offline

Posts: 1715658763

View Profile Personal Message (Offline)

Ignore
1715658763
Reply with quote  #2

1715658763
Report to moderator
The network tries to produce one block per 10 minutes. It does this by automatically adjusting how difficult it is to produce blocks.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715658763
Hero Member
*
Offline Offline

Posts: 1715658763

View Profile Personal Message (Offline)

Ignore
1715658763
Reply with quote  #2

1715658763
Report to moderator
elmigranto
Newbie
*
Offline Offline

Activity: 8
Merit: 0


View Profile WWW
June 29, 2011, 07:13:33 PM
 #2

You send following json to server if you need data to work on:
Code:
{"method":"getwork","params":[],"id":"json"}
Sever responds with:
Code:
{	"id":"json", "error":null,
"result":{
"midstate":"0e8a0e8d83ae508c1a0859c3a298d86676904b83803ac67323ed2c51d8e2d7f3",
"target":"ffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000",
"data":"00000001cddc2362bc4b15ef5ebf6fef9dd58bcb24ca1f05596bcd9e0000078400000000f5354d24f29a46e2c1ecf861795ffe4f26ee7cc0755098b2421dc823b42b16264e0b78c41a0c2a1200000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000080020000",
"hash1":"00000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000010000"
}
}

Quote
Is block data just the header?
It's header in big-endian hexademical format with additional bytes for SHA256 (see wiki on SHA256 for details).

Quote
When a miner hits the target, how does it send the nonce back?
Same getwork reqeuest as first one in this post, except params isn't empty and has work-data with valid nonce. In hexademical big-endian ofcourse.
See source code of any miner for more details.
TierNolan (OP)
Legendary
*
Offline Offline

Activity: 1232
Merit: 1083


View Profile
June 29, 2011, 07:49:42 PM
 #3

Same getwork reqeuest as first one in this post, except params isn't empty and has work-data with valid nonce. In hexademical big-endian ofcourse.
See source code of any miner for more details.

Thanks for the info.

1LxbG5cKXzTwZg9mjL3gaRE835uNQEteWF
Sukrim
Legendary
*
Offline Offline

Activity: 2618
Merit: 1006


View Profile
July 06, 2011, 12:43:39 AM
 #4

Could someone enlighten me what this "id" field is good for? poclbm puts "json" in there, phoenix a single lonely 1... both receive the same getwork data though from a pool server.

https://www.coinlend.org <-- automated lending at various exchanges.
https://www.bitfinex.com <-- Trade BTC for other currencies and vice versa.
shads
Sr. Member
****
Offline Offline

Activity: 266
Merit: 254


View Profile
July 06, 2011, 03:44:40 AM
 #5

"id" is part of the JSON-RPC spec.  All requests are supposed to have an id unique to that client, the server response should include the same id.  Presumably for matching asyncronous requests with response though you'd be able to track it by connection anyway.

It's supposed to be an integer.  I think most bitcoin related implementations ignore it.

PoolServerJ Home Page - High performance java mining pool engine

Quote from: Matthew N. Wright
Stop wasting the internet.
shads
Sr. Member
****
Offline Offline

Activity: 266
Merit: 254


View Profile
July 06, 2011, 03:55:32 AM
 #6

It's header in big-endian hexademical format with additional bytes for SHA256 (see wiki on SHA256 for details).

Can you give a link for this?  I've search all over and can't find anywhere that explains how the padding should be done?  I'm currently trying to work out how to turn a header in byte array form back into a valid getwork hex string.

PoolServerJ Home Page - High performance java mining pool engine

Quote from: Matthew N. Wright
Stop wasting the internet.
kjj
Legendary
*
Offline Offline

Activity: 1302
Merit: 1025



View Profile
July 06, 2011, 01:52:50 PM
 #7

It's header in big-endian hexademical format with additional bytes for SHA256 (see wiki on SHA256 for details).

Can you give a link for this?  I've search all over and can't find anywhere that explains how the padding should be done?  I'm currently trying to work out how to turn a header in byte array form back into a valid getwork hex string.

FIPS 180-3

You want section 5.  Note that the message length is stored in Intel's crazy-endian format.

17Np17BSrpnHCZ2pgtiMNnhjnsWJ2TMqq8
I routinely ignore posters with paid advertising in their sigs.  You should too.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!