Bitcoin Forum
April 24, 2024, 08:22:22 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Getwork/Mining, I sorta get it....  (Read 1538 times)
BinoX (OP)
Full Member
***
Offline Offline

Activity: 140
Merit: 100


View Profile
December 22, 2011, 01:12:15 AM
Last edit: December 22, 2011, 12:04:44 PM by BinoX
 #1

Maybe I'm being stupid (and it's a high probability) or maybe I'm just tired...

I'm sat here writing a simple bitcoin miner to teach myself about how it all works...

This things I understand:

You "getwork" from the server, which gives you a message with midstate, data, hash1 and target in it.
I know that "data" is the important one.
Data splits up into Version, Previous Hash, Merkle Root, Timestamp, target/"bits", Nonce.
I know that you then do the SHA256 hashing bit (and I know about the double hashing) then increment the nonce and rehash and repeat until you find the "answer"


What I don't get is that when the nonce overflows you need to increment "extraNonce" and reset the nonce back to 0... WHERE is the extra nonce and HOW do you do it? Or is it just a case of sending another getwork request? Also, does this method change if you're solo mining or on a pool...

I did a search of the forums, but I didn't really understand what I was reading... Please put it in terms that idiots would understand Smiley Or give a nice example of some sort, lol

Thanks in advance.
1713990142
Hero Member
*
Offline Offline

Posts: 1713990142

View Profile Personal Message (Offline)

Ignore
1713990142
Reply with quote  #2

1713990142
Report to moderator
1713990142
Hero Member
*
Offline Offline

Posts: 1713990142

View Profile Personal Message (Offline)

Ignore
1713990142
Reply with quote  #2

1713990142
Report to moderator
1713990142
Hero Member
*
Offline Offline

Posts: 1713990142

View Profile Personal Message (Offline)

Ignore
1713990142
Reply with quote  #2

1713990142
Report to moderator
Unlike traditional banking where clients have only a few account numbers, with Bitcoin people can create an unlimited number of accounts (addresses). This can be used to easily track payments, and it improves anonymity.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
BinoX (OP)
Full Member
***
Offline Offline

Activity: 140
Merit: 100


View Profile
December 24, 2011, 09:16:03 PM
 #2

Bump.

I will be documenting this fully to help people in the future. But I want to be sure that I understand it fully before I start in case I miss something important out!
DeathAndTaxes
Donator
Legendary
*
Offline Offline

Activity: 1218
Merit: 1079


Gerald Davis


View Profile
December 24, 2011, 09:26:55 PM
 #3

The extra nonce is put in the coinbase field of the coinbase transaction.  Essentially any value change there results in a new transaction hash and thus a new merkle tree root.  This is done by the mining pool server.

So simplified.
1) You send getwork to pool
2) Pool returns data as you describe
3) You begin w/ nonce of 0.
4) Load nonce into block header and perform double sha-256 hash.
6) If the hash is < target for difficulty 1 you submit it to the server as a share (pool checks each share to see if it meets full difficulty)
7) Increment hash and go to step 4.  If you reach max nonce (2^32 -1) then goto step 1

In solo mining it works very similar except there is no "server" you are sending requests directly to the bitcoind.


Now "good" miners do some efficiency improvements.  They request getworks pre-emptively but that is the basics on miner pool communications.  Also on a longpool you need to discard any stale getworks and work on new data.

So it requires at least one getwork per 2^32 hashes (1 share).  To make it a little more complex there is a method called n-time-rolling which allows the miner to simply increment the time locally.  This allows multiple runs through the nonce range on one getwork request.
BinoX (OP)
Full Member
***
Offline Offline

Activity: 140
Merit: 100


View Profile
December 24, 2011, 11:03:06 PM
 #4

Thank you very much. That's pretty much what I'd suspected...

Over the next week (or a little more, I have many other projects) I'll build up a simple cpu based miner and build up some documentation from there.

You never know, it might turn into a much bigger project, I do fancy building a miner anyway....
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!