| 1635 | } |
| 1636 | |
| 1637 | void Client::configure_from_command_line(int argc, char** argv) { |
| 1638 | if (argc == 0 && argv == nullptr) { |
| 1639 | my->_cli = new thinkyoung::cli::Cli(this, nullptr, &std::cout); |
| 1640 | return; |
| 1641 | } |
| 1642 | |
| 1643 | g_client = this; |
| 1644 | // parse command-line options |
| 1645 | auto option_variables = parse_option_variables(argc, argv); |
| 1646 | fc::path datadir = thinkyoung::client::get_data_dir(option_variables); |
| 1647 | fc::path walletDir = thinkyoung::client::get_wallet_dir(option_variables, datadir); |
| 1648 | |
| 1649 | if (!fc::exists(datadir)) { |
| 1650 | std::cout << "Creating new data directory " << datadir.preferred_string() << "\n"; |
| 1651 | fc::create_directories(datadir); |
| 1652 | #ifndef WIN32 |
| 1653 | int perm = 0700; |
| 1654 | std::cout << "Setting UNIX permissions on new data directory to " << std::oct << perm << std::dec << "\n"; |
| 1655 | fc::chmod(datadir, perm); |
| 1656 | #else |
| 1657 | std::cout << "Note: new data directory is readable by all user accounts on non-UNIX OS\n"; |
| 1658 | #endif |
| 1659 | } |
| 1660 | |
| 1661 | if (!fc::exists(walletDir)) { |
| 1662 | std::cout << "Creating new wallet directory " << walletDir.preferred_string() << "\n"; |
| 1663 | fc::create_directories(walletDir); |
| 1664 | #ifndef WIN32 |
| 1665 | int perm = 0700; |
| 1666 | std::cout << "Setting UNIX permissions on new data directory to " << std::oct << perm << std::dec << "\n"; |
| 1667 | fc::chmod(walletDir, perm); |
| 1668 | #else |
| 1669 | std::cout << "Note: new wallet directory is readable by all user accounts on non-UNIX OS\n"; |
| 1670 | #endif |
| 1671 | } |
| 1672 | |
| 1673 | // this just clears the database if the command line says |
| 1674 | load_and_configure_chain_database(datadir, option_variables); |
| 1675 | fc::optional<fc::path> genesis_file_path; |
| 1676 | |
| 1677 | if (option_variables.count("genesis-config")) |
| 1678 | genesis_file_path = option_variables["genesis-config"].as<string>(); |
| 1679 | |
| 1680 | my->_enable_ulog = option_variables["ulog"].as<bool>(); |
| 1681 | fc::optional<bool> statistics_enabled; |
| 1682 | |
| 1683 | if (option_variables.count("statistics-enabled") > 0) statistics_enabled = true; |
| 1684 | |
| 1685 | this->open(datadir, walletDir, genesis_file_path, statistics_enabled); |
| 1686 | |
| 1687 | if (option_variables.count("min-delegate-connection-count")) |
| 1688 | my->_delegate_config.network_min_connection_count = option_variables["min-delegate-connection-count"].as<uint32_t>(); |
| 1689 | |
| 1690 | this->configure(datadir); |
| 1691 | |
| 1692 | if (option_variables.count("max-connections")) { |
| 1693 | my->_config.maximum_number_of_connections = option_variables["max-connections"].as<uint16_t>(); |
| 1694 | fc::mutable_variant_object params; |
no test coverage detected