Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: Endlessa on May 09, 2013, 04:59:38 PM



Title: Can someone point me to the entry point where mining code lives?
Post by: Endlessa on May 09, 2013, 04:59:38 PM
I've been working my way through a lot of information as I setup hardware, learn about finance, dig into the mechanics etc.
I'm a programmer at heart and have been desiring a deeper understanding of the underlying code responsible for mining.
I've lived most my life doing back-end, so I get a bit lost in UI programming ;) any help pointing me to the underlying code would be greatly appreciated.

I've already through the P2P discovery bit, but I'm really more interested in the following code locations:

  • Where does new difficulty get calculated?
  • Where is the code that propagates new difficulty to the mining nodes?
  • Where is the code that deals with nuts and bolts of mining live? (Blockchain processing)

Any help or assistance would be hugely appreciated as I would love to knock the green off my understanding of the overall process :)

Also I will be sequence diagramming this code (and probably some other code) and documenting the functions.  I would be happy to share this with the dev community. Is there a preferred place or should I just use the regular bitcoin wiki?

I may also be doing local classes for developers (and some non-developers) and possible some online courses.  I will most likely be putting the curriculum into public domain.

Thanks :)





Title: Re: Can someone point me to the entry point where mining code lives?
Post by: kjj on May 09, 2013, 05:07:18 PM
Did you read the sticky at the top of this board?


Title: Re: Can someone point me to the entry point where mining code lives?
Post by: Endlessa on May 09, 2013, 05:14:07 PM
Did you read the sticky at the top of this board?

Yes did I miss something there? I didn't see where mining code was identified.  I read the specifications, but my understanding is the literal implementation of the code is where the facts live.  I'm hoping to map the facts of the code to the protocol specifications.


I looked again I assume you mean the "Satoshi Client Operation: Overview", but I'm still not seeing where it references mining.  :) let me know if I tarded out or something, as I'm a bit sleepy today and that is entirely possible :)


Title: Re: Can someone point me to the entry point where mining code lives?
Post by: Endlessa on May 09, 2013, 05:19:31 PM
It did just occur to me that maybe what I'm looking for is actually in the open source mining clients combined with where the bitcoin client validates the proper block chain when a solution collision occurs.  Is this true? Maybe all I need from the bitcoin client is the solution collision/split resolution code? combined with some digging into mining clients? Anybody familiar with this?


Title: Re: Can someone point me to the entry point where mining code lives?
Post by: jonytk on May 09, 2013, 08:19:57 PM
Endlessa, with 17 posts...
post your credentials, or you are just another alt-developer or 4chan troll trying to hack a coin to make it proffitable.

If you are a proffessor, i think you need to lurk moar... i remember there's some wiki, satoshi pdf and threads explaining everything.

Use the Search first! You will find nice articles. or just look at the sourcecode!


Title: Re: Can someone point me to the entry point where mining code lives?
Post by: Endlessa on May 09, 2013, 08:52:10 PM
I am new without a doubt. I did make the mistake of thinking the forum was here to ask for help.  I guess I went to the wrong place.  Don't worry I will search the code I have the source, was just hoping some kind person would be helpful to people trying educate the community at large.  I thought this "community" project might be supportive of a community question. I was hoping someone might have a link set they'd share so I don't spend ages reproducing something somebody might have to share. . . .ya know like built on the shoulders of giants and all. No worries, I'll just use cpp2dia and keep the whole thing to myself.  thanks for being a dick.


Title: Re: Can someone point me to the entry point where mining code lives?
Post by: kjj on May 09, 2013, 08:56:46 PM
Endlessa, with 17 posts...
post your credentials, or you are just another alt-developer or 4chan troll trying to hack a coin to make it proffitable.

If you are a proffessor, i think you need to lurk moar... i remember there's some satoshi pdf and threads explaining everything.
Search or just look at the sourcecode!

That's a bit rude, don't you think?  Why do you care why he wants to learn more about the source?

Did you read the sticky at the top of this board?

Yes did I miss something there? I didn't see where mining code was identified.  I read the specifications, but my understanding is the literal implementation of the code is where the facts live.  I'm hoping to map the facts of the code to the protocol specifications.

I looked again I assume you mean the "Satoshi Client Operation: Overview", but I'm still not seeing where it references mining.  :) let me know if I tarded out or something, as I'm a bit sleepy today and that is entirely possible :)

As far as I know, those articles (links at the bottom to the others) are the best guide to the source that anyone has written up so far.  I'm not sure if they will tell you where to look exactly, but I had hoped that they may at least get you pointed in the right direction.


Title: Re: Can someone point me to the entry point where mining code lives?
Post by: Endlessa on May 09, 2013, 09:05:44 PM
Quote

As far as I know, those articles (links at the bottom to the others) are the best guide to the source that anyone has written up so far.  I'm not sure if they will tell you where to look exactly, but I had hoped that they may at least get you pointed in the right direction.

Awesome thanks, at least I know I'm in the right spot. From the code I've been reading so far it seems that the mining programs use JSON RPC with bitcoind then apply the appropriate hashes and merkle tree structure to it, check to see if it's a viable solution. if it is, they then JSON RPC submit the new block to submitblock. continue processing, the next block while waiting for confirmation.  Does it sound like I'm on the right track?


Title: Re: Can someone point me to the entry point where mining code lives?
Post by: Endlessa on May 09, 2013, 09:07:58 PM
Quote
it seems that the mining programs use JSON RPC

*it seems that the mining programs use JSON RPC to get the last block, then they assemble a set of transaction to build a new block to hash against.  The Nonce is the incrementor to change the hash while searching for a compliant hash result? right? maybe ;).


Title: Re: Can someone point me to the entry point where mining code lives?
Post by: Endlessa on May 09, 2013, 10:37:49 PM
Anyone looking to understand this in the future, here is the link I was looking for and it should get you started.

https://bitcointalk.org/index.php?topic=108854.0



Title: Re: Can someone point me to the entry point where mining code lives?
Post by: twobits on May 09, 2013, 11:49:48 PM
I think at this point the mining code has been ripped out of the current versions.  It may be easier conceptional to go back to a version that was all in one to see the mining all in one source base.