Bitcoin Forum
December 07, 2016, 10:26:23 PM *
News: Latest stable version of Bitcoin Core: 0.13.1  [Torrent].
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: Getwork RPC call question  (Read 1675 times)
TierNolan
Legendary
*
Offline Offline

Activity: 1036


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
1481149583
Hero Member
*
Offline Offline

Posts: 1481149583

View Profile Personal Message (Offline)

Ignore
1481149583
Reply with quote  #2

1481149583
Report to moderator
1481149583
Hero Member
*
Offline Offline

Posts: 1481149583

View Profile Personal Message (Offline)

Ignore
1481149583
Reply with quote  #2

1481149583
Report to moderator
1481149583
Hero Member
*
Offline Offline

Posts: 1481149583

View Profile Personal Message (Offline)

Ignore
1481149583
Reply with quote  #2

1481149583
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
elmigranto
Newbie
*
Offline Offline

Activity: 8


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.

I'm sorry I can't hear you over the sound of how awesome I am.
TierNolan
Legendary
*
Offline Offline

Activity: 1036


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: 1848


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://bitfinex.com <-- leveraged trading of BTCUSD, LTCUSD and LTCBTC (long and short) - 10% discount on fees for the first 30 days with this refcode: x5K9YtL3Zb
Mail me at Bitmessage: BM-BbiHiVv5qh858ULsyRDtpRrG9WjXN3xf
shads
Full Member
***
Offline Offline

Activity: 224


View Profile WWW
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

1LezqRatQz7MeNoCVziYwcdwtqeEbvrdAq - http://payb.tc/shads

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

Activity: 224


View Profile WWW
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

1LezqRatQz7MeNoCVziYwcdwtqeEbvrdAq - http://payb.tc/shads

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

Activity: 1302



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.

p2pcoin: a USB/CD/PXE p2pool miner - 1N8ZXx2cuMzqBYSK72X4DAy1UdDbZQNPLf - todo
I routinely ignore posters with paid advertising in their sigs.  You should too.
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!