The last time in the Ubuntu system in the source code compilation environment set up, has not specifically analyzed the inside of the codes, today we will read. The source version is BITCOIN-0.9.5RC2.
We say that verifying the success of the Bitcoin client installation is verified from the which bitcoind command because there are two Bitcoin clients. One is the version of the graphical interface, often referred to as Bitcoin (capitalized), and a simple version of the command line (called Bitcoind).
Let's start with the Bitcoind command line because it's less code and feels simple (hehe). I found the bitcoind.cpp file under the SRC directory of the source code. But did not find bitcoind.h file, I do not know why. But it didn't affect us to look at the code.
The entry for a C + + program is performed from the main () function. We also look at it from here. Bitcoind main function
The code is simple, and we're going through the line.
One. The Setupenvironment function is defined in Src/util.cpp. setupenvironment function
This function sets the local run environment. The purpose of this function is to set different codes for internationalization based on different countries.
Two. Noui_connect
A signal handler that connects the Bitcoind client. My understanding is that the signal handler is the various messages that listen to the program, including the exception message, the hardware exception message, or the normal signal message of the program.
Three. Appinit ()
Application initialization, actually there's a lot of bread around here.
1. Parseparameters ()//parse the parameters of running input and put the parameters into Mapargs; Mapmultiargs; These two map objects.
2. Determine if the data directory exists and read the configuration file specified by the profile parameter
3. Determine the legality of parameters testnet Regtest parameters and whether they are entered--help or-? Gets the parameters for the help information.
4. The output of the JSON data format is obtained according to the input parameters and combined with the corresponding results.
5. Set the appropriate settings (APPINIT2) According to the input parameters and open a new thread, always listening for messages exiting the program.
This is the bitcoind.cpp inside the code content, the analysis may not be very accurate for reference only, may also find in later reading the error. We first understand the work flow and the approximate framework.
I've drawn a flowchart to illustrate how the client works. The flowchart is as follows:
Author: Blockchain Workshop bitcoin source study class, Black
Interested in developing BTC Coins friends can add Exchange Group 649747998, Unauthorized, may not reprint Author: ttblack Link: http://www.jianshu.com/p/4a5b0c0f9984 Source: Pinterest Copyright belongs to the author. Commercial reprint please contact the author for authorization, non-commercial reprint please specify the source.