/**
bitcoind.cpp 启动源码
*/
//source code
int main(int argc, char* argv[])
{
SetupEnvironment(); //util.cpp
// Connect bitcoind signal handlers
noui_connect();
return (AppInit(argc, argv) ? EXIT_SUCCESS : EXIT_FAILURE);
}
//代码测试
intmain() {
std::cout<<"Hello, World!"<
return0;
}
//文件路径 src/util.cpp
/**
* Server/client environment: argument handling, config file parsing,
* thread wrappers, startup time
*/
void SetupEnvironment()
{
#ifdef HAVE_MALLOPT_ARENA_MAX
// glibc-specific: On 32-bit systems set the number of arenas to 1.
// By default, since glibc 2.10, the C library will create up to two heap
// arenas per core. This is known to cause excessive virtual address space
// usage in our usage. Work around it by setting the maximum number of
// arenas to 1.
//内存分配区设置
//Win32索引32位地址(4字节),X64索引64位地址(8字节)
if (sizeof(void*) == 4) {
mallopt(M_ARENA_MAX, 1);
}
#endif
// On most POSIX systems (e.g. Linux, but not BSD) the environment's locale
// may be invalid, in which case the "C" locale is used as fallback.
/**
[michael@s132-148-91-102 ~]$ locale
*LANG=en_US.UTF-8
*LC_CTYPE="en_US.UTF-8"
*LC_NUMERIC="en_US.UTF-8"
*LC_TIME="en_US.UTF-8"
*LC_COLLATE="en_US.UTF-8"
*LC_MONETARY="en_US.UTF-8"
*LC_MESSAGES="en_US.UTF-8"
*LC_PAPER="en_US.UTF-8"
*LC_NAME="en_US.UTF-8"
*LC_ADDRESS="en_US.UTF-8"
*LC_TELEPHONE="en_US.UTF-8"
*LC_MEASUREMENT="en_US.UTF-8"
*LC_IDENTIFICATION="en_US.UTF-8"
*LC_ALL=
*/
#if !defined(WIN32) && !defined(MAC_OSX) && !defined(__FreeBSD__) && !defined(__OpenBSD__)
try {
std::locale(""); // Raises a runtime error if current locale is invalid
} catch (const std::runtime_error&) {
setenv("LC_ALL", "C", 1);
}
#endif
// The path locale is lazy initialized and to avoid deinitialization errors
// in multithreading environments, it is set explicitly by the main thread.
// A dummy locale is used to extract the internal default locale, used by
// fs::path, which is then used to explicitly imbue the path.
//文件系统的本地化设置
std::locale loc = fs::path::imbue(std::locale::classic());
fs::path::imbue(loc);
}
// src/noui.cpp // no ui connect
// #include// #includevoid noui_connect()
{
// Connect bitcoind signal handlers
uiInterface.ThreadSafeMessageBox.connect(noui_ThreadSafeMessageBox);
uiInterface.ThreadSafeQuestion.connect(noui_ThreadSafeQuestion);
uiInterface.InitMessage.connect(noui_InitMessage);
}
/**
* boost
* Boost provides free peer-reviewed portable C++ source libraries.
*/