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

Function main

tools/integrity_check/main.cpp:377–466  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

375}
376
377int main(int argc, char * argv[]) {
378 std::string configLocation;
379 std::string outputFile;
380 std::ofstream out;
381 bool runTxIndexCheck = false;
382 bool runNestingIndexCheck = false;
383 std::streambuf *coutbuf = nullptr;
384 int endBlock = 0;
385
386 auto cli = (
387 clipp::value("config file location", configLocation) % "Path to config file",
388 (clipp::option("--file", "-f") & clipp::value("output file", outputFile)) % "Write to file instead of std::cout",
389 clipp::option("--txindex", "-t").set(runTxIndexCheck).doc("Run tx index check"),
390 clipp::option("--nestingindex", "-n").set(runNestingIndexCheck).doc("Run nesting address index check")
391 );
392
393 auto res = parse(argc, argv, cli);
394 if (res.any_error()) {
395 std::cout << "Invalid command line parameter\n" << clipp::make_man_page(cli, argv[0]);
396 return 0;
397 }
398
399 // Write to file instead of stdout
400 if(!outputFile.empty()) {
401 out.open(outputFile);
402 coutbuf = std::cout.rdbuf();
403 std::cout.rdbuf(out.rdbuf());
404 }
405
406 Blockchain chain(configLocation, endBlock);
407
408 const DataAccess &dataAccess = chain.getAccess();
409 const ChainAccess &chainAccess = dataAccess.getChain();
410
411 std::cout << "Chain contains " << chain.size() << " blocks, " << chain.getAccess().getChain().txCount() << " txes, " << chain.getAccess().getChain().inputCount() << " inputs, " << chain.getAccess().getChain().outputCount() << " outputs." << std::endl;
412
413 std::cout << std::endl << "Blocks:" << std::endl;
414 auto block_hash = compute_block_hash(chainAccess);
415 std::cout << block_hash.GetHex() << " (BLOCKS)" << std::endl;
416
417 std::cout << std::endl << "Transactions:" << std::endl;
418 auto txdata_hash = compute_txdata_hash(chainAccess);
419 std::cout << txdata_hash.GetHex() << " (TXES)" << std::endl;
420
421 std::cout << std::endl << "Additional data:" << std::endl;
422 auto additional_data_hash = compute_additional_data_hash(dataAccess);
423 std::cout << additional_data_hash.GetHex() << " (ADDITIONAL)" << std::endl;
424
425 std::cout << std::endl << "Scripts:" << std::endl;
426
427 auto scripthash_hash = compute_scriptdata_hash<DedupAddressType::SCRIPTHASH>(dataAccess);
428 std::cout << scripthash_hash.GetHex() << " (SCRIPTHASH)" << std::endl;
429
430 auto pubkey_hash = compute_scriptdata_hash<DedupAddressType::PUBKEY>(dataAccess);
431 std::cout << pubkey_hash.GetHex() << " (PUBKEY)" << std::endl;
432
433 auto multisig_hash = compute_scriptdata_hash<DedupAddressType::MULTISIG>(dataAccess);
434 std::cout << multisig_hash.GetHex() << " (MULTISIG)" << std::endl;

Callers

nothing calls this directly

Calls 12

compute_block_hashFunction · 0.85
compute_txdata_hashFunction · 0.85
check_hashindex_txindexFunction · 0.85
txCountMethod · 0.80
inputCountMethod · 0.80
outputCountMethod · 0.80
GetHexMethod · 0.80
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected