Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: Jon on March 26, 2012, 05:07:13 AM



Title: I am trying to read the Bitcoin source code, again.
Post by: Jon on March 26, 2012, 05:07:13 AM
Tell me, in what folder and with what file do I begin? What libraries do I need to know about?

I have never written anything this large -- much less read through it.


Title: Re: I am trying to read the Bitcoin source code, again.
Post by: marked on March 26, 2012, 09:15:23 AM
use Doxygen (http://www.doxygen.org)? though it probably depends on how well the code is commented.

Generally you start with /src/main.cpp and then follow the execution paths.

Alternatively load the project into an IDE that can follow functions, headers, etc.

marked


Title: Re: I am trying to read the Bitcoin source code, again.
Post by: Jon on March 26, 2012, 09:40:11 AM
use Doxygen (http://www.doxygen.org)? though it probably depends on how well the code is commented.

Generally you start with /src/main.cpp and then follow the execution paths.

Alternatively load the project into an IDE that can follow functions, headers, etc.

marked

Righto. Thanks. I really should try studying the syntax of C++ rather than applying prior knowledge from other languages. >_<


Title: Re: I am trying to read the Bitcoin source code, again.
Post by: ribuck on March 26, 2012, 09:42:40 AM
It's a big task to read the entire source code in one go. Reading source code "in the abstract" is hard work.

Why not pick some aspect that particularly interests you. For example: coin allocation, or the user interface for the address book, or block discouragement, or whatever. Then explore that part of the code.

Better still, find a change you'd be interested in making. That forces you to get to grips with that part of the code.

Oh, and have you even compiled the source code yourself? That's the first step, and it can be an interesting and educational experience in itself (especially on Fedora or Red Hat where you'll need to overcome some dependencies). Even if you don't plan to make any software changes, the building the application will help you become familiar with its files.


Title: Re: I am trying to read the Bitcoin source code, again.
Post by: Jon on March 26, 2012, 09:47:29 AM
It's a big task to read the entire source code in one go. Reading source code "in the abstract" is hard work.

Why not pick some aspect that particularly interests you. For example: coin allocation, or the user interface for the address book, or block discouragement, or whatever. Then explore that part of the code.

Better still, find a change you'd be interested in making. That forces you to get to grips with that part of the code.

Oh, and have you even compiled the source code yourself? That's the first step, and it can be an interesting and educational experience in itself (especially on Fedora or Red Hat where you'll need to overcome some dependencies). Even if you don't plan to make any software changes, the building the application will help you become familiar with its files.

Let's just say I come up with goals too big for my own good. I will probably end up settling for something small at the end of this.

Yeah, I'll compile it first. That's pretty essential.


Title: Re: I am trying to read the Bitcoin source code, again.
Post by: Gavin Andresen on March 26, 2012, 03:58:57 PM
Start with this stickied thread. (https://bitcointalk.org/index.php?topic=41718.0)


Title: Re: I am trying to read the Bitcoin source code, again.
Post by: fivebells on March 26, 2012, 04:25:08 PM
The version control history is pretty well organized.  I have gotten some mileage out of browsing it with gitk.   Also, libcoin is a fork which sells itself as a drop-in bitcoin replacement with better organized source code.  Might be worth a look.