MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / AppInit

Function AppInit

src/bitcoind.cpp:57–182  ·  view source on GitHub ↗

///////////////////////////////////////////////////////////////////////// Start

Source from the content-addressed store, hash-verified

55// Start
56//
57static bool AppInit(int argc, char* argv[])
58{
59 bool fRet = false;
60
61 //
62 // Parameters
63 //
64 // If Qt is used, parameters/bitcoingold.conf are parsed in qt/bitcoin.cpp's main()
65 SetupServerArgs();
66 std::string error;
67 if (!gArgs.ParseParameters(argc, argv, error)) {
68 fprintf(stderr, "Error parsing command line arguments: %s\n", error.c_str());
69 return false;
70 }
71
72 // Process help and version before taking care about datadir
73 if (HelpRequested(gArgs) || gArgs.IsArgSet("-version")) {
74 std::string strUsage = PACKAGE_NAME " Daemon version " + FormatFullVersion() + "\n";
75
76 if (gArgs.IsArgSet("-version"))
77 {
78 strUsage += FormatParagraph(LicenseInfo());
79 }
80 else
81 {
82 strUsage += "\nUsage: bgoldd [options] Start " PACKAGE_NAME " Daemon\n";
83 strUsage += "\n" + gArgs.GetHelpMessage();
84 }
85
86 fprintf(stdout, "%s", strUsage.c_str());
87 return true;
88 }
89
90 try
91 {
92 if (!fs::is_directory(GetDataDir(false)))
93 {
94 fprintf(stderr, "Error: Specified data directory \"%s\" does not exist.\n", gArgs.GetArg("-datadir", "").c_str());
95 return false;
96 }
97 if (!gArgs.ReadConfigFiles(error, true)) {
98 fprintf(stderr, "Error reading configuration file: %s\n", error.c_str());
99 return false;
100 }
101 // Check for -testnet or -regtest parameter (Params() calls are only valid after this clause)
102 try {
103 SelectParams(gArgs.GetChainName());
104 } catch (const std::exception& e) {
105 fprintf(stderr, "Error: %s\n", e.what());
106 return false;
107 }
108
109 // Error out when loose non-argument tokens are encountered on command line
110 for (int i = 1; i < argc; i++) {
111 if (!IsSwitchChar(argv[i][0])) {
112 fprintf(stderr, "Error: Command line contains unexpected token '%s', see bgoldd -h for a list of options.\n", argv[i]);
113 return false;
114 }

Callers 1

mainFunction · 0.85

Calls 15

SetupServerArgsFunction · 0.85
HelpRequestedFunction · 0.85
FormatFullVersionFunction · 0.85
FormatParagraphFunction · 0.85
LicenseInfoFunction · 0.85
SelectParamsFunction · 0.85
IsSwitchCharFunction · 0.85
InitLoggingFunction · 0.85
InitParameterInteractionFunction · 0.85
AppInitBasicSetupFunction · 0.85
AppInitSanityChecksFunction · 0.85

Tested by

no test coverage detected