diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5a79325ef..6010e3805 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -105,7 +105,6 @@ add_subdirectory(wallet) add_subdirectory(p2p) add_subdirectory(cryptonote_protocol) -add_subdirectory(miner) add_subdirectory(simplewallet) add_subdirectory(daemonizer) add_subdirectory(daemon) diff --git a/src/blockchain_utilities/CMakeLists.txt b/src/blockchain_utilities/CMakeLists.txt index d98c2ce83..6f62128cc 100644 --- a/src/blockchain_utilities/CMakeLists.txt +++ b/src/blockchain_utilities/CMakeLists.txt @@ -58,26 +58,6 @@ bitmonero_private_headers(blockchain_export ${blockchain_export_private_headers}) -set(blockchain_dump_sources - blockchain_dump.cpp - ) - -set(blockchain_dump_private_headers) - -bitmonero_private_headers(blockchain_dump - ${blockchain_dump_private_headers}) - - -set(cn_deserialize_sources - cn_deserialize.cpp - ) - -set(cn_deserialize_private_headers) - -bitmonero_private_headers(cn_deserialize - ${cn_deserialize_private_headers}) - - bitmonero_add_executable(blockchain_import ${blockchain_import_sources} ${blockchain_import_private_headers}) @@ -98,7 +78,7 @@ add_dependencies(blockchain_import version) set_property(TARGET blockchain_import PROPERTY - OUTPUT_NAME "blockchain_import") + OUTPUT_NAME "monero-blockchain-import") bitmonero_add_executable(blockchain_export ${blockchain_export_sources} @@ -115,38 +95,4 @@ add_dependencies(blockchain_export version) set_property(TARGET blockchain_export PROPERTY - OUTPUT_NAME "blockchain_export") - -bitmonero_add_executable(blockchain_dump - ${blockchain_dump_sources} - ${blockchain_dump_private_headers}) - -target_link_libraries(blockchain_dump - LINK_PRIVATE - cryptonote_core - blockchain_db - p2p - ${CMAKE_THREAD_LIBS_INIT}) - -add_dependencies(blockchain_dump - version) -set_property(TARGET blockchain_dump - PROPERTY - OUTPUT_NAME "blockchain_dump") - -bitmonero_add_executable(cn_deserialize - ${cn_deserialize_sources} - ${cn_deserialize_private_headers}) - -target_link_libraries(cn_deserialize - LINK_PRIVATE - cryptonote_core - p2p - ${CMAKE_THREAD_LIBS_INIT}) - -add_dependencies(cn_deserialize - version) -set_property(TARGET cn_deserialize - PROPERTY - OUTPUT_NAME "cn_deserialize") - + OUTPUT_NAME "monero-blockchain-export") diff --git a/src/blockchain_utilities/blockchain_dump.cpp b/src/blockchain_utilities/blockchain_dump.cpp deleted file mode 100644 index 626900d42..000000000 --- a/src/blockchain_utilities/blockchain_dump.cpp +++ /dev/null @@ -1,417 +0,0 @@ -// Copyright (c) 2014-2016, The Monero Project -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without modification, are -// permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this list of -// conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright notice, this list -// of conditions and the following disclaimer in the documentation and/or other -// materials provided with the distribution. -// -// 3. Neither the name of the copyright holder nor the names of its contributors may be -// used to endorse or promote products derived from this software without specific -// prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF -// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#include "cryptonote_core/cryptonote_basic.h" -#include "cryptonote_core/blockchain.h" -#include "cryptonote_core/tx_pool.h" -#include "blockchain_db/blockchain_db.h" -#include "blockchain_db/lmdb/db_lmdb.h" -#ifdef BERKELEY_DB -#include "blockchain_db/berkeleydb/db_bdb.h" -#endif -#include "blockchain_utilities.h" -#include "common/command_line.h" -#include "version.h" - -namespace po = boost::program_options; -using namespace epee; // log_space - -using namespace cryptonote; - -struct DumpContext { - std::ofstream &f; - size_t level; - std::vector close; - - DumpContext(std::ofstream &f): f(f), level(0) {} -}; - -template static void start_compound(DumpContext &d, S key, bool array, bool print = false) -{ - if (print) - LOG_PRINT_L0("Dumping " << key << "..."); - d.f << std::string(d.level*2, ' '); - d.f << "\"" << key << "\": " << (array ? "[" : "{") << " \n"; - d.close.push_back(array ? "]" : "}"); - d.level++; -} - -template static void start_array(DumpContext &d, S key, bool print = false) { start_compound(d, key, true, print); } -template static void start_struct(DumpContext &d, S key, bool print = false) { start_compound(d, key, false, print); } - -static void end_compound(DumpContext &d) -{ - d.level--; - d.f << std::string(d.level*2, ' '); - d.f << d.close.back() << ",\n"; - d.close.pop_back(); -} - -template static void write_pod(DumpContext &d, S key, const T &t) -{ - d.f << std::string(d.level*2, ' '); - d.f << "\"" << key << "\": "; - d.f << t; - d.f << ",\n"; -} - -template static void write_pod(DumpContext &d, const T &t) -{ - d.f << std::string(d.level*2, ' '); - d.f << t; - d.f << ",\n"; -} - -int main(int argc, char* argv[]) -{ - uint32_t log_level = 0; - uint64_t block_stop = 0; - - tools::sanitize_locale(); - - boost::filesystem::path default_data_path {tools::get_default_data_dir()}; - boost::filesystem::path default_testnet_data_path {default_data_path / "testnet"}; - boost::filesystem::path output_file_path; - - po::options_description desc_cmd_only("Command line options"); - po::options_description desc_cmd_sett("Command line options and settings options"); - const command_line::arg_descriptor arg_output_file = {"output-file", "Specify output file", "", true}; - const command_line::arg_descriptor arg_log_level = {"log-level", "", log_level}; - const command_line::arg_descriptor arg_block_stop = {"block-stop", "Stop at block number", block_stop}; - const command_line::arg_descriptor arg_db_type = { - "db-type" - , "Specify database type" - , DEFAULT_DB_TYPE - }; - const command_line::arg_descriptor arg_include_db_only_data = { - "include-db-only-data" - , "Include data that is only in a database version." - , false - }; - const command_line::arg_descriptor arg_testnet_on = { - "testnet" - , "Run on testnet." - , false - }; - - - command_line::add_arg(desc_cmd_sett, command_line::arg_data_dir, default_data_path.string()); - command_line::add_arg(desc_cmd_sett, command_line::arg_testnet_data_dir, default_testnet_data_path.string()); - command_line::add_arg(desc_cmd_sett, arg_output_file); - command_line::add_arg(desc_cmd_sett, arg_db_type); - command_line::add_arg(desc_cmd_sett, arg_include_db_only_data); - command_line::add_arg(desc_cmd_sett, arg_testnet_on); - command_line::add_arg(desc_cmd_sett, arg_log_level); - command_line::add_arg(desc_cmd_sett, arg_block_stop); - - command_line::add_arg(desc_cmd_only, command_line::arg_help); - - po::options_description desc_options("Allowed options"); - desc_options.add(desc_cmd_only).add(desc_cmd_sett); - - po::variables_map vm; - bool r = command_line::handle_error_helper(desc_options, [&]() - { - po::store(po::parse_command_line(argc, argv, desc_options), vm); - po::notify(vm); - return true; - }); - if (! r) - return 1; - - if (command_line::get_arg(vm, command_line::arg_help)) - { - std::cout << "Monero '" << MONERO_RELEASE_NAME << "' (v" << MONERO_VERSION_FULL << ")" << ENDL << ENDL; - std::cout << desc_options << std::endl; - return 1; - } - - log_level = command_line::get_arg(vm, arg_log_level); - block_stop = command_line::get_arg(vm, arg_block_stop); - - log_space::get_set_log_detalisation_level(true, log_level); - log_space::log_singletone::add_logger(LOGGER_CONSOLE, NULL, NULL); - LOG_PRINT_L0("Starting..."); - LOG_PRINT_L0("Setting log level = " << log_level); - - bool opt_testnet = command_line::get_arg(vm, arg_testnet_on); - bool opt_include_db_only_data = command_line::get_arg(vm, arg_include_db_only_data); - - std::string m_config_folder; - - auto data_dir_arg = opt_testnet ? command_line::arg_testnet_data_dir : command_line::arg_data_dir; - m_config_folder = command_line::get_arg(vm, data_dir_arg); - - if (command_line::has_arg(vm, arg_output_file)) - output_file_path = boost::filesystem::path(command_line::get_arg(vm, arg_output_file)); - else - output_file_path = boost::filesystem::path(m_config_folder) / "dump" / "blockchain.json"; - LOG_PRINT_L0("Export output file: " << output_file_path.string()); - - const boost::filesystem::path dir_path = output_file_path.parent_path(); - if (!dir_path.empty()) - { - if (boost::filesystem::exists(dir_path)) - { - if (!boost::filesystem::is_directory(dir_path)) - { - LOG_PRINT_RED_L0("dump directory path is a file: " << dir_path); - return 1; - } - } - else - { - if (!boost::filesystem::create_directory(dir_path)) - { - LOG_PRINT_RED_L0("Failed to create directory " << dir_path); - return 1; - } - } - } - - std::ofstream raw_data_file; - raw_data_file.open(output_file_path.string(), std::ios_base::out | std::ios::trunc); - if (raw_data_file.fail()) - return 1; - - - // If we wanted to use the memory pool, we would set up a fake_core. - - // Use Blockchain instead of lower-level BlockchainDB for two reasons: - // 1. Blockchain has the init() method for easy setup - // 2. exporter needs to use get_current_blockchain_height(), get_block_id_by_height(), get_block_by_hash() - // - // cannot match blockchain_storage setup above with just one line, - // e.g. - // Blockchain* core_storage = new Blockchain(NULL); - // because unlike blockchain_storage constructor, which takes a pointer to - // tx_memory_pool, Blockchain's constructor takes tx_memory_pool object. - LOG_PRINT_L0("Initializing source blockchain (BlockchainDB)"); - Blockchain *core_storage = NULL; - tx_memory_pool m_mempool(*core_storage); - core_storage = new Blockchain(m_mempool); - - BlockchainDB* db; - int mdb_flags = 0; - std::string db_type = command_line::get_arg(vm, arg_db_type); - if (db_type.empty() || db_type == "lmdb") - { - db = new BlockchainLMDB(); - mdb_flags |= MDB_RDONLY; - } -#ifdef BERKELEY_DB - else if (db_type == "berkeley") - { - db = new BlockchainBDB(); - // can't open readonly due to the way flags are split in db_bdb.cpp - } -#endif - else - { - LOG_PRINT_L0("Invalid db type: " << db_type); - return 1; - } - boost::filesystem::path folder(m_config_folder); - folder /= db->get_db_name(); - const std::string filename = folder.string(); - uint64_t base_idx = db->get_indexing_base(); - - LOG_PRINT_L0("Loading blockchain from folder " << filename << " ..."); - try - { - db->open(filename, mdb_flags); - } - catch (const std::exception& e) - { - LOG_PRINT_L0("Error opening database: " << e.what()); - return 1; - } - r = core_storage->init(db, opt_testnet); - - CHECK_AND_ASSERT_MES(r, false, "Failed to initialize source blockchain storage"); - LOG_PRINT_L0("Source blockchain storage initialized OK"); - LOG_PRINT_L0("Dumping blockchain..."); - - DumpContext d(raw_data_file); - - start_struct(d,"blockchain"); - uint64_t height = core_storage->get_current_blockchain_height(); - write_pod(d, "height", height); - start_array(d,"blockids", true); - for (uint64_t h = 0; h < height; ++h) - write_pod(d,core_storage->get_block_id_by_height(h)); - end_compound(d); - start_array(d,"txids", true); - { - std::vector txids; - core_storage->for_all_transactions([&txids](const crypto::hash &hash, const cryptonote::transaction &tx)->bool{txids.push_back(hash); return true;}); - std::sort(txids.begin(), txids.end(), - [](const crypto::hash &txid0, const crypto::hash &txid1) {return memcmp(txid0.data, txid1.data, sizeof(crypto::hash::data)) < 0;}); - for (size_t n = 0; n < txids.size(); ++n) - write_pod(d, txids[n]); - } - end_compound(d); - start_struct(d,"transactions", true); - { - for (uint64_t h = 0; h < height; ++h) - { - start_array(d, boost::lexical_cast(h)); - std::list blocks; - std::list transactions, miner_tx; - core_storage->get_blocks(h, 1, blocks, transactions); - if (blocks.size() != 1) - throw std::string("Expected 1 block at height ") + boost::lexical_cast(h); - crypto::hash txid = cryptonote::get_transaction_hash(blocks.front().miner_tx); - write_pod(d, string_tools::pod_to_hex(txid).c_str(), obj_to_json_str(blocks.front().miner_tx)); - std::vector> txes; - for (std::list::iterator i = transactions.begin(); i != transactions.end(); ++i) - txes.push_back(std::make_pair(cryptonote::get_transaction_hash(*i), *i)); - std::sort(txes.begin(), txes.end(), - [](const std::pair &tx0, const std::pair &tx1) {return memcmp(tx0.first.data, tx1.first.data, sizeof(crypto::key_image::data)) < 0;}); - for (std::vector>::iterator i = txes.begin(); i != txes.end(); ++i) - { - write_pod(d, string_tools::pod_to_hex((*i).first).c_str(), obj_to_json_str((*i).second)); - } - end_compound(d); - } - } - end_compound(d); - start_struct(d,"blocks", true); - { - std::vector blockids; - core_storage->for_all_blocks([&](uint64_t height, const crypto::hash &hash, const cryptonote::block &b)->bool{ - start_struct(d, boost::lexical_cast(height)); - write_pod(d, "hash", string_tools::pod_to_hex(hash)); - cryptonote::block block = b; - write_pod(d, "block", obj_to_json_str(block)); - end_compound(d); - return true; - }); - } - end_compound(d); - start_array(d,"key_images", true); - { - std::vector key_images; - core_storage->for_all_key_images([&key_images](const crypto::key_image &k_image)->bool{key_images.push_back(k_image); return true;}); - std::sort(key_images.begin(), key_images.end(), - [](const crypto::key_image &k0, const crypto::key_image &k1) {return memcmp(k0.data, k1.data, sizeof(crypto::key_image::data)) < 0;}); - for (size_t n = 0; n < key_images.size(); ++n) - write_pod(d,key_images[n]); - } - end_compound(d); - if (opt_include_db_only_data) - { - start_struct(d, "block_timestamps", true); - for (uint64_t h = 0; h < height; ++h) - write_pod(d,boost::lexical_cast(h),db->get_block_timestamp(h)); - end_compound(d); - start_struct(d, "block_difficulties", true); - for (uint64_t h = 0; h < height; ++h) - write_pod(d,boost::lexical_cast(h),db->get_block_cumulative_difficulty(h)); - end_compound(d); - start_struct(d, "block_sizes", true); - for (uint64_t h = 0; h < height; ++h) - write_pod(d,boost::lexical_cast(h),db->get_block_size(h)); - end_compound(d); - start_struct(d, "block_coins", true); - for (uint64_t h = 0; h < height; ++h) - write_pod(d,boost::lexical_cast(h),db->get_block_already_generated_coins(h)); - end_compound(d); - start_struct(d, "block_heights", true); - for (uint64_t h = 0; h < height; ++h) - { - const crypto::hash hash = core_storage->get_block_id_by_height(h); - write_pod(d,boost::lexical_cast(h),db->get_block_height(hash)); - } - end_compound(d); - { - std::vector txids; - core_storage->for_all_transactions([&txids](const crypto::hash &hash, const cryptonote::transaction &tx)->bool{txids.push_back(hash); return true;}); - std::sort(txids.begin(), txids.end(), - [](const crypto::hash &txid0, const crypto::hash &txid1) {return memcmp(txid0.data, txid1.data, sizeof(crypto::hash::data)) < 0;}); - start_struct(d, "transaction_unlock_times", true); - for (size_t n = 0; n < txids.size(); ++n) - write_pod(d,string_tools::pod_to_hex(txids[n]),db->get_tx_unlock_time(txids[n])); - end_compound(d); - start_struct(d, "transaction_block_heights", true); - for (size_t n = 0; n < txids.size(); ++n) - write_pod(d,string_tools::pod_to_hex(txids[n]),db->get_tx_block_height(txids[n])); - end_compound(d); - } - start_array(d, "tx_and_index_from_global", true); - for (uint64_t idx = 0; ; ++idx) - { - try - { - tx_out_index toi = db->get_output_tx_and_index_from_global(idx + base_idx); - start_struct(d, boost::lexical_cast(idx)); - write_pod(d, "tx_hash", string_tools::pod_to_hex(toi.first)); - write_pod(d, "tx_index", string_tools::pod_to_hex(toi.second)); - end_compound(d); - } - catch (const OUTPUT_DNE &) { break; } - } - end_compound(d); - start_struct(d, "outputs_amounts", true); - for (uint64_t base = 1; base <= (uint64_t)10000000000000000000ul; base *= 10) for (uint64_t digit = 1; digit <= 9; ++digit) { - uint64_t amount = digit * base; - write_pod(d, boost::lexical_cast(amount), db->get_num_outputs(amount)); - } - end_compound(d); - start_array(d, "output_keys", true); - for (uint64_t idx = 0; ; ++idx) - { - try - { - output_data_t od = db->get_output_key(idx + base_idx); - start_struct(d, boost::lexical_cast(idx)); - write_pod(d, "pubkey", string_tools::pod_to_hex(od.pubkey)); - write_pod(d, "unlock_time", od.unlock_time); - write_pod(d, "height", od.height); - end_compound(d); - } - catch (const OUTPUT_DNE &) { break; } - } - end_compound(d); - start_struct(d, "hf_versions", true); - for (uint64_t h = 0; h < height; ++h) - write_pod(d, boost::lexical_cast(h), (unsigned int)db->get_hard_fork_version(h)); - end_compound(d); - } - end_compound(d); - - CHECK_AND_ASSERT_MES(r, false, "Failed to dump blockchain"); - - if (raw_data_file.fail()) - return 1; - raw_data_file.flush(); - - LOG_PRINT_L0("Blockchain dump OK"); - - return 0; -} diff --git a/src/blockchain_utilities/cn_deserialize.cpp b/src/blockchain_utilities/cn_deserialize.cpp deleted file mode 100644 index a8448dcee..000000000 --- a/src/blockchain_utilities/cn_deserialize.cpp +++ /dev/null @@ -1,190 +0,0 @@ -// Copyright (c) 2014-2016, The Monero Project -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without modification, are -// permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this list of -// conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright notice, this list -// of conditions and the following disclaimer in the documentation and/or other -// materials provided with the distribution. -// -// 3. Neither the name of the copyright holder nor the names of its contributors may be -// used to endorse or promote products derived from this software without specific -// prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF -// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#include "cryptonote_core/cryptonote_basic.h" -#include "cryptonote_core/tx_extra.h" -#include "cryptonote_core/blockchain.h" -#include "blockchain_utilities.h" -#include "common/command_line.h" -#include "version.h" - -namespace po = boost::program_options; -using namespace epee; // log_space - -using namespace cryptonote; - -int main(int argc, char* argv[]) -{ - uint32_t log_level = 0; - std::string input; - - tools::sanitize_locale(); - - boost::filesystem::path output_file_path; - - po::options_description desc_cmd_only("Command line options"); - po::options_description desc_cmd_sett("Command line options and settings options"); - const command_line::arg_descriptor arg_output_file = {"output-file", "Specify output file", "", true}; - const command_line::arg_descriptor arg_log_level = {"log-level", "", log_level}; - const command_line::arg_descriptor arg_input = {"input", "Specify input has a hexadecimal string", ""}; - - command_line::add_arg(desc_cmd_sett, arg_output_file); - command_line::add_arg(desc_cmd_sett, arg_log_level); - command_line::add_arg(desc_cmd_sett, arg_input); - - command_line::add_arg(desc_cmd_only, command_line::arg_help); - - po::options_description desc_options("Allowed options"); - desc_options.add(desc_cmd_only).add(desc_cmd_sett); - - po::variables_map vm; - bool r = command_line::handle_error_helper(desc_options, [&]() - { - po::store(po::parse_command_line(argc, argv, desc_options), vm); - po::notify(vm); - return true; - }); - if (! r) - return 1; - - if (command_line::get_arg(vm, command_line::arg_help)) - { - std::cout << "Monero '" << MONERO_RELEASE_NAME << "' (v" << MONERO_VERSION_FULL << ")" << ENDL << ENDL; - std::cout << desc_options << std::endl; - return 1; - } - - log_level = command_line::get_arg(vm, arg_log_level); - input = command_line::get_arg(vm, arg_input); - if (input.empty()) - { - std::cerr << "--input is mandatory" << std::endl; - return 1; - } - - log_space::get_set_log_detalisation_level(true, log_level); - log_space::log_singletone::add_logger(LOGGER_CONSOLE, NULL, NULL); - - std::string m_config_folder; - - std::ostream *output; - std::ofstream *raw_data_file = NULL; - if (command_line::has_arg(vm, arg_output_file)) - { - output_file_path = boost::filesystem::path(command_line::get_arg(vm, arg_output_file)); - - const boost::filesystem::path dir_path = output_file_path.parent_path(); - if (!dir_path.empty()) - { - if (boost::filesystem::exists(dir_path)) - { - if (!boost::filesystem::is_directory(dir_path)) - { - std::cerr << "output directory path is a file: " << dir_path << std::endl; - return 1; - } - } - else - { - if (!boost::filesystem::create_directory(dir_path)) - { - std::cerr << "Failed to create directory " << dir_path << std::endl; - return 1; - } - } - } - - raw_data_file = new std::ofstream(); - raw_data_file->open(output_file_path.string(), std::ios_base::out | std::ios::trunc); - if (raw_data_file->fail()) - return 1; - output = raw_data_file; - } - else - { - output_file_path = ""; - output = &std::cout; - } - - cryptonote::blobdata blob; - if (!epee::string_tools::parse_hexstr_to_binbuff(input, blob)) - { - std::cerr << "Invalid hex input" << std::endl; - std::cerr << "Invalid hex input: " << input << std::endl; - return 1; - } - - cryptonote::block block; - cryptonote::transaction tx; - std::vector fields; - if (cryptonote::parse_and_validate_block_from_blob(blob, block)) - { - std::cout << "Parsed block:" << std::endl; - std::cout << cryptonote::obj_to_json_str(block) << std::endl; - } - else if (cryptonote::parse_and_validate_tx_from_blob(blob, tx)) - { - std::cout << "Parsed transaction:" << std::endl; - std::cout << cryptonote::obj_to_json_str(tx) << std::endl; - - if (cryptonote::parse_tx_extra(tx.extra, fields)) - { - std::cout << "tx_extra has " << fields.size() << " field(s)" << std::endl; - for (size_t n = 0; n < fields.size(); ++n) - { - std::cout << "field " << n << ": "; - if (typeid(cryptonote::tx_extra_padding) == fields[n].type()) std::cout << "extra padding: " << boost::get(fields[n]).size << " bytes"; - else if (typeid(cryptonote::tx_extra_pub_key) == fields[n].type()) std::cout << "extra pub key: " << boost::get(fields[n]).pub_key; - else if (typeid(cryptonote::tx_extra_nonce) == fields[n].type()) std::cout << "extra nonce: " << epee::string_tools::buff_to_hex_nodelimer(boost::get(fields[n]).nonce); - else if (typeid(cryptonote::tx_extra_merge_mining_tag) == fields[n].type()) std::cout << "extra merge mining tag: depth " << boost::get(fields[n]).depth << ", merkle root " << boost::get(fields[n]).merkle_root; - else if (typeid(cryptonote::tx_extra_mysterious_minergate) == fields[n].type()) std::cout << "extra minergate custom: " << epee::string_tools::buff_to_hex_nodelimer(boost::get(fields[n]).data); - else std::cout << "unknown"; - std::cout << std::endl; - } - } - else - { - std::cout << "Failed to parse tx_extra" << std::endl; - } - } - else - { - std::cerr << "Not a recognized CN type" << std::endl; - return 1; - } - - - - if (output->fail()) - return 1; - output->flush(); - if (raw_data_file) - delete raw_data_file; - - return 0; -} diff --git a/src/daemon/CMakeLists.txt b/src/daemon/CMakeLists.txt index e456ccba6..511efcb36 100644 --- a/src/daemon/CMakeLists.txt +++ b/src/daemon/CMakeLists.txt @@ -105,4 +105,4 @@ target_link_libraries(daemon add_dependencies(daemon version) set_property(TARGET daemon PROPERTY - OUTPUT_NAME "bitmonerod") + OUTPUT_NAME "monerod") diff --git a/src/miner/CMakeLists.txt b/src/miner/CMakeLists.txt deleted file mode 100644 index d065b9950..000000000 --- a/src/miner/CMakeLists.txt +++ /dev/null @@ -1,56 +0,0 @@ -# Copyright (c) 2014-2016, The Monero Project -# -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without modification, are -# permitted provided that the following conditions are met: -# -# 1. Redistributions of source code must retain the above copyright notice, this list of -# conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above copyright notice, this list -# of conditions and the following disclaimer in the documentation and/or other -# materials provided with the distribution. -# -# 3. Neither the name of the copyright holder nor the names of its contributors may be -# used to endorse or promote products derived from this software without specific -# prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -# THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF -# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -set(simpleminer_sources - simpleminer.cpp) - -set(simpleminer_headers) - -set(simpleminer_private_headers - simpleminer.h - simpleminer_protocol_defs.h - target_helper.h) - -bitmonero_private_headers(simpleminer - ${simpleminer_private_headers}) -bitmonero_add_executable(simpleminer - ${simpleminer_sources} - ${simpleminer_headers} - ${simpleminer_private_headers}) -target_link_libraries(simpleminer - LINK_PRIVATE - cryptonote_core - common - ${Boost_FILESYSTEM_LIBRARY} - ${Boost_PROGRAM_OPTIONS_LIBRARY} - ${Boost_REGEX_LIBRARY} - ${Boost_CHRONO_LIBRARY} - ${Boost_SYSTEM_LIBRARY} - ${Boost_THREAD_LIBRARY} - ${CMAKE_THREAD_LIBS_INIT} - ${EXTRA_LIBRARIES}) diff --git a/src/miner/simpleminer.cpp b/src/miner/simpleminer.cpp deleted file mode 100644 index ba956d90b..000000000 --- a/src/miner/simpleminer.cpp +++ /dev/null @@ -1,246 +0,0 @@ -// Copyright (c) 2014-2016, The Monero Project -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without modification, are -// permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this list of -// conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright notice, this list -// of conditions and the following disclaimer in the documentation and/or other -// materials provided with the distribution. -// -// 3. Neither the name of the copyright holder nor the names of its contributors may be -// used to endorse or promote products derived from this software without specific -// prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF -// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers - -#include "common/command_line.h" -#include "misc_log_ex.h" -#include "simpleminer.h" -#include "target_helper.h" -#include "net/http_server_handlers_map2.h" -#include "simpleminer_protocol_defs.h" -#include "storages/http_abstract_invoke.h" -#include "string_tools.h" -#include "cryptonote_core/account.h" -#include "cryptonote_core/cryptonote_format_utils.h" - -using namespace epee; -namespace po = boost::program_options; - -int main(int argc, char** argv) -{ - string_tools::set_module_name_and_folder(argv[0]); - - //set up logging options - log_space::get_set_log_detalisation_level(true, LOG_LEVEL_4); - log_space::log_singletone::add_logger(LOGGER_CONSOLE, NULL, NULL); - log_space::log_singletone::add_logger(LOGGER_FILE, - log_space::log_singletone::get_default_log_file().c_str(), - log_space::log_singletone::get_default_log_folder().c_str()); - - po::options_description desc("Allowed options"); - command_line::add_arg(desc, command_line::arg_help); - mining::simpleminer::init_options(desc); - - //uint32_t t = mining::get_target_for_difficulty(700000); - - po::variables_map vm; - bool r = command_line::handle_error_helper(desc, [&]() - { - po::store(po::parse_command_line(argc, argv, desc), vm); - po::notify(vm); - - if (command_line::get_arg(vm, command_line::arg_help)) - { - std::cout << desc << std::endl; - return false; - } - - return true; - }); - if (!r) - return 1; - - mining::simpleminer miner; - r = miner.init(vm); - r = r && miner.run(); // Never returns... - - return 0; -} - - - -namespace mining -{ - const command_line::arg_descriptor arg_pool_addr = {"pool-addr", ""}; - const command_line::arg_descriptor arg_login = {"login", ""}; - const command_line::arg_descriptor arg_pass = {"pass", ""}; - - //----------------------------------------------------------------------------------------------------- - void simpleminer::init_options(boost::program_options::options_description& desc) - { - command_line::add_arg(desc, arg_pool_addr); - command_line::add_arg(desc, arg_login); - command_line::add_arg(desc, arg_pass); - } - bool simpleminer::init(const boost::program_options::variables_map& vm) - { - std::string pool_addr = command_line::get_arg(vm, arg_pool_addr); - //parse ip and address - std::string::size_type p = pool_addr.find(':'); - CHECK_AND_ASSERT_MES(p != std::string::npos && (p + 1 != pool_addr.size()), false, "Wrong srv address syntax"); - m_pool_ip = pool_addr.substr(0, p); - m_pool_port = pool_addr.substr(p + 1, pool_addr.size()); - m_login = command_line::get_arg(vm, arg_login); - m_pass = command_line::get_arg(vm, arg_pass); - return true; - } - - bool simpleminer::text_job_details_to_native_job_details(const job_details& job, simpleminer::job_details_native& native_details) - { - bool r = epee::string_tools::parse_hexstr_to_binbuff(job.blob, native_details.blob); - CHECK_AND_ASSERT_MES(r, false, "wrong buffer sent from pool server"); - r = epee::string_tools::parse_tpod_from_hex_string(job.target, native_details.target); - CHECK_AND_ASSERT_MES(r, false, "wrong buffer sent from pool server"); - native_details.job_id = job.job_id; - return true; - } - - bool simpleminer::run() - { - std::string pool_session_id; - simpleminer::job_details_native job = AUTO_VAL_INIT(job); - uint64_t last_job_ticks = 0; - - while(true) - { - //----------------- - last_job_ticks = epee::misc_utils::get_tick_count(); - if(!m_http_client.is_connected()) - { - LOG_PRINT_L0("Connecting " << m_pool_ip << ":" << m_pool_port << "...."); - if(!m_http_client.connect(m_pool_ip, m_pool_port, 20000)) - { - LOG_PRINT_L0("Failed to connect " << m_pool_ip << ":" << m_pool_port << ", sleep...."); - epee::misc_utils::sleep_no_w(1000); - continue; - } - //DO AUTH - LOG_PRINT_L0("Connected " << m_pool_ip << ":" << m_pool_port << " OK"); - COMMAND_RPC_LOGIN::request req = AUTO_VAL_INIT(req); - req.login = m_login; - req.pass = m_pass; - req.agent = "simpleminer/0.1"; - COMMAND_RPC_LOGIN::response resp = AUTO_VAL_INIT(resp); - if(!epee::net_utils::invoke_http_json_rpc("/", req, resp, m_http_client)) - { - LOG_PRINT_L0("Failed to invoke login " << m_pool_ip << ":" << m_pool_port << ", disconnect and sleep...."); - m_http_client.disconnect(); - epee::misc_utils::sleep_no_w(1000); - continue; - } - if(resp.status != "OK" || resp.id.empty()) - { - LOG_PRINT_L0("Failed to login " << m_pool_ip << ":" << m_pool_port << ", disconnect and sleep...."); - m_http_client.disconnect(); - epee::misc_utils::sleep_no_w(1000); - continue; - } - pool_session_id = resp.id; - //78 - if (resp.job.blob.empty() && resp.job.target.empty() && resp.job.job_id.empty()) - { - LOG_PRINT_L0("Job didn't change"); - continue; - } - else if(!text_job_details_to_native_job_details(resp.job, job)) - { - LOG_PRINT_L0("Failed to text_job_details_to_native_job_details(), disconnect and sleep...."); - m_http_client.disconnect(); - epee::misc_utils::sleep_no_w(1000); - continue; - } - last_job_ticks = epee::misc_utils::get_tick_count(); - - } - while(epee::misc_utils::get_tick_count() - last_job_ticks < 20000) - { - //uint32_t c = (*((uint32_t*)&job.blob.data()[39])); - ++(*((uint32_t*)&job.blob.data()[39])); - crypto::hash h = cryptonote::null_hash; - crypto::cn_slow_hash(job.blob.data(), job.blob.size(), h); - if( ((uint32_t*)&h)[7] < job.target ) - { - //found! - - COMMAND_RPC_SUBMITSHARE::request submit_request = AUTO_VAL_INIT(submit_request); - COMMAND_RPC_SUBMITSHARE::response submit_response = AUTO_VAL_INIT(submit_response); - submit_request.id = pool_session_id; - submit_request.job_id = job.job_id; - submit_request.nonce = epee::string_tools::pod_to_hex((*((uint32_t*)&job.blob.data()[39]))); - submit_request.result = epee::string_tools::pod_to_hex(h); - LOG_PRINT_L0("Share found: nonce=" << submit_request.nonce << " for job=" << job.job_id << ", submitting..."); - if(!epee::net_utils::invoke_http_json_rpc("/", submit_request, submit_response, m_http_client)) - { - LOG_PRINT_L0("Failed to submit share! disconnect and sleep...."); - m_http_client.disconnect(); - epee::misc_utils::sleep_no_w(1000); - break; - } - if(submit_response.status != "OK") - { - LOG_PRINT_L0("Failed to submit share! (submitted share rejected) disconnect and sleep...."); - m_http_client.disconnect(); - epee::misc_utils::sleep_no_w(1000); - break; - } - LOG_PRINT_GREEN("Share submitted successfully!", LOG_LEVEL_0); - break; - } - } - //get next job - COMMAND_RPC_GETJOB::request getjob_request = AUTO_VAL_INIT(getjob_request); - COMMAND_RPC_GETJOB::response getjob_response = AUTO_VAL_INIT(getjob_response); - getjob_request.id = pool_session_id; - LOG_PRINT_L0("Getting next job..."); - if(!epee::net_utils::invoke_http_json_rpc("/", getjob_request, getjob_response, m_http_client)) - { - LOG_PRINT_L0("Can't get new job! Disconnect and sleep...."); - m_http_client.disconnect(); - epee::misc_utils::sleep_no_w(1000); - continue; - } - if (getjob_response.blob.empty() && getjob_response.target.empty() && getjob_response.job_id.empty()) - { - LOG_PRINT_L0("Job didn't change"); - continue; - } - else if(!text_job_details_to_native_job_details(getjob_response, job)) - { - LOG_PRINT_L0("Failed to text_job_details_to_native_job_details(), disconnect and sleep...."); - m_http_client.disconnect(); - epee::misc_utils::sleep_no_w(1000); - continue; - } - last_job_ticks = epee::misc_utils::get_tick_count(); - } - - return true; - - } -} diff --git a/src/miner/simpleminer.h b/src/miner/simpleminer.h deleted file mode 100644 index 177a562b3..000000000 --- a/src/miner/simpleminer.h +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) 2014-2016, The Monero Project -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without modification, are -// permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this list of -// conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright notice, this list -// of conditions and the following disclaimer in the documentation and/or other -// materials provided with the distribution. -// -// 3. Neither the name of the copyright holder nor the names of its contributors may be -// used to endorse or promote products derived from this software without specific -// prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF -// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers - -#pragma once -#include "net/http_client.h" -#include "cryptonote_protocol/blobdatatype.h" -#include "simpleminer_protocol_defs.h" -namespace mining -{ - class simpleminer - { - public: - static void init_options(boost::program_options::options_description& desc); - bool init(const boost::program_options::variables_map& vm); - bool run(); - private: - struct job_details_native - { - cryptonote::blobdata blob; - uint32_t target; - std::string job_id; - }; - - static bool text_job_details_to_native_job_details(const job_details& job, job_details_native& native_details); - - std::string m_pool_ip; - std::string m_pool_port; - std::string m_login; - std::string m_pass; - epee::net_utils::http::http_simple_client m_http_client; - }; -} diff --git a/src/miner/simpleminer_protocol_defs.h b/src/miner/simpleminer_protocol_defs.h deleted file mode 100644 index 29c5fb3ec..000000000 --- a/src/miner/simpleminer_protocol_defs.h +++ /dev/null @@ -1,134 +0,0 @@ -// Copyright (c) 2014-2016, The Monero Project -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without modification, are -// permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this list of -// conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright notice, this list -// of conditions and the following disclaimer in the documentation and/or other -// materials provided with the distribution. -// -// 3. Neither the name of the copyright holder nor the names of its contributors may be -// used to endorse or promote products derived from this software without specific -// prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF -// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers - -#pragma once -#include "cryptonote_protocol/cryptonote_protocol_defs.h" -#include "cryptonote_core/cryptonote_basic.h" -#include "crypto/hash.h" -#include "net/rpc_method_name.h" - -namespace mining -{ - //----------------------------------------------- -#define CORE_RPC_STATUS_OK "OK" - - - struct job_details - { - std::string blob; - std::string target; - std::string job_id; - - BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(blob) - KV_SERIALIZE(target) - KV_SERIALIZE(job_id) - END_KV_SERIALIZE_MAP() - }; - - - struct COMMAND_RPC_LOGIN - { - RPC_METHOD_NAME("login"); - - struct request - { - std::string login; - std::string pass; - std::string agent; - - BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(login) - KV_SERIALIZE(pass) - KV_SERIALIZE(agent) - END_KV_SERIALIZE_MAP() - }; - - - struct response - { - std::string status; - std::string id; - job_details job; - - BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(status) - KV_SERIALIZE(id) - KV_SERIALIZE(job) - END_KV_SERIALIZE_MAP() - }; - }; - - struct COMMAND_RPC_GETJOB - { - RPC_METHOD_NAME("getjob"); - - struct request - { - std::string id; - - BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(id) - END_KV_SERIALIZE_MAP() - }; - - typedef job_details response; - }; - - struct COMMAND_RPC_SUBMITSHARE - { - RPC_METHOD_NAME("submit"); - - struct request - { - std::string id; - std::string nonce; - std::string result; - std::string job_id; - - BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(id) - KV_SERIALIZE(nonce) - KV_SERIALIZE(result) - KV_SERIALIZE(job_id) - END_KV_SERIALIZE_MAP() - }; - - struct response - { - std::string status; - - BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(status) - END_KV_SERIALIZE_MAP() - }; - }; -} - diff --git a/src/miner/target_helper.h b/src/miner/target_helper.h deleted file mode 100644 index d12f7edae..000000000 --- a/src/miner/target_helper.h +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) 2014-2016, The Monero Project -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without modification, are -// permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this list of -// conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright notice, this list -// of conditions and the following disclaimer in the documentation and/or other -// materials provided with the distribution. -// -// 3. Neither the name of the copyright holder nor the names of its contributors may be -// used to endorse or promote products derived from this software without specific -// prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF -// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers - -#pragma once -#include "cryptonote_core/difficulty.h" - - -namespace mining -{ - inline uint32_t get_target_for_difficulty(cryptonote::difficulty_type difficulty) - { - if(!difficulty) - return 0xffffffff; - return 0xffffffff/static_cast(difficulty); - } - -} diff --git a/src/simplewallet/CMakeLists.txt b/src/simplewallet/CMakeLists.txt index 96d812361..97852c3dc 100644 --- a/src/simplewallet/CMakeLists.txt +++ b/src/simplewallet/CMakeLists.txt @@ -57,3 +57,6 @@ target_link_libraries(simplewallet ${EXTRA_LIBRARIES}) add_dependencies(simplewallet version) +set_property(TARGET simplewallet + PROPERTY + OUTPUT_NAME "monero-wallet-cli") \ No newline at end of file