MCPcopy Create free account
hub / github.com/citp/BlockSci / checkConfigFile

Method checkConfigFile

tools/parser/doctor.cpp:42–93  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40}
41
42void BlockSciDoctor::checkConfigFile() {
43 printInfo("Checking configuration for issues.");
44
45 blocksci::ChainConfiguration chainConfig = jsonConf.at("chainConfig");
46
47 auto dataDirectory = chainConfig.dataDirectory;
48 if(!dataDirectory.exists()) {
49 printWarning("Data directory does not exist.");
50 warnings += 1;
51
52 if(!filesystem::create_directory(dataDirectory)) {
53 std::stringstream ss;
54 ss << "Cannot create directory for path " << dataDirectory << ". Check file permissions.";
55 printError(ss.str());
56 errors += 1;
57 }
58 } else {
59 printOk("Found data directory on disk.");
60 }
61
62 // Parser
63 auto parserConf = jsonConf.at("parser");
64 bool hasRPCConfig = parserConf.find("rpc") != parserConf.end();
65 bool hasDiskConfig = parserConf.find("disk") != parserConf.end();
66
67 if (!hasRPCConfig && !hasDiskConfig) {
68 std::cout << "Error: config contains neither disk nor RPC parsing settings." << std::endl;
69 errors += 1;
70 }
71 if (hasDiskConfig){
72 printOk("Found disk parser settings in config.");
73 }
74 if (hasRPCConfig) {
75 printOk("Found RPC parser settings in config.");
76 }
77
78 // Disk parser
79 if (hasDiskConfig) {
80 ChainDiskConfiguration diskConfig = parserConf.at("disk");
81
82 auto coinDirectory = diskConfig.coinDirectory;
83 auto blockDirectory = coinDirectory/"blocks";
84
85 if(!coinDirectory.exists()) {
86 printError("Coin directory does not exist.");
87 errors += 1;
88 } else if(coinDirectory.exists() && !blockDirectory.exists()) {
89 printError("Coin directory does not contain blocks subdirectory.");
90 errors += 1;
91 }
92 }
93}
94
95void BlockSciDoctor::rebuildChainIndex() {
96 blocksci::ChainConfiguration chainConfig = jsonConf.at("chainConfig");

Callers 1

mainFunction · 0.80

Calls 7

printInfoFunction · 0.85
printWarningFunction · 0.85
printErrorFunction · 0.85
printOkFunction · 0.85
existsMethod · 0.80
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected