diff options
author | mikezackles <mikezackles@gmail.com> | 2014-07-17 19:23:49 -0400 |
---|---|---|
committer | mikezackles <mikezackles@gmail.com> | 2014-07-17 19:23:49 -0400 |
commit | 905b67bc790a09940bc22a4f199516b2b0157cdd (patch) | |
tree | d616ea77f177a5e412022b74122acf62320e5a03 /src | |
parent | Merge pull request #56 from tewinget/master (diff) | |
parent | Fix thread count argument handling in simplewallet (diff) | |
download | monero-905b67bc790a09940bc22a4f199516b2b0157cdd.tar.xz |
Merge pull request #63 from mikezackles/bytecoin_for_merge
Misc fixes from bytecoin
Diffstat (limited to 'src')
-rw-r--r-- | src/common/base58.cpp | 2 | ||||
-rw-r--r-- | src/crypto/slow-hash.c | 1 | ||||
-rw-r--r-- | src/cryptonote_core/blockchain_storage.cpp | 19 | ||||
-rw-r--r-- | src/cryptonote_core/cryptonote_core.cpp | 41 | ||||
-rw-r--r-- | src/cryptonote_core/cryptonote_core.h | 7 | ||||
-rw-r--r-- | src/cryptonote_core/cryptonote_format_utils.cpp | 2 | ||||
-rw-r--r-- | src/cryptonote_core/cryptonote_format_utils.h | 1 | ||||
-rw-r--r-- | src/p2p/net_node.inl | 2 | ||||
-rw-r--r-- | src/rpc/core_rpc_server_commands_defs.h | 10 | ||||
-rw-r--r-- | src/serialization/binary_utils.h | 2 | ||||
-rw-r--r-- | src/serialization/crypto.h | 2 | ||||
-rw-r--r-- | src/serialization/json_utils.h | 2 | ||||
-rw-r--r-- | src/serialization/vector.h | 7 | ||||
-rw-r--r-- | src/simplewallet/simplewallet.cpp | 4 | ||||
-rw-r--r-- | src/wallet/wallet_errors.h | 10 |
15 files changed, 52 insertions, 60 deletions
diff --git a/src/common/base58.cpp b/src/common/base58.cpp index 454c0db67..575279aa5 100644 --- a/src/common/base58.cpp +++ b/src/common/base58.cpp @@ -110,7 +110,7 @@ namespace tools void encode_block(const char* block, size_t size, char* res) { - assert(1 <= size && size <= sizeof(full_block_size)); + assert(1 <= size && size <= full_block_size); uint64_t num = uint_8be_to_64(reinterpret_cast<const uint8_t*>(block), size); int i = static_cast<int>(encoded_block_sizes[size]) - 1; diff --git a/src/crypto/slow-hash.c b/src/crypto/slow-hash.c index b4a1c8085..ba95cf679 100644 --- a/src/crypto/slow-hash.c +++ b/src/crypto/slow-hash.c @@ -350,7 +350,6 @@ void cn_slow_hash(const void *data, size_t length, char *hash) RDATA_ALIGN16 uint64_t a[2]; RDATA_ALIGN16 uint64_t b[2]; RDATA_ALIGN16 uint64_t c[2]; - RDATA_ALIGN16 uint8_t aes_key[AES_KEY_SIZE]; union cn_slow_hash_state state; __m128i _a, _b, _c; uint64_t hi, lo; diff --git a/src/cryptonote_core/blockchain_storage.cpp b/src/cryptonote_core/blockchain_storage.cpp index 9e9c77e85..a545b6c61 100644 --- a/src/cryptonote_core/blockchain_storage.cpp +++ b/src/cryptonote_core/blockchain_storage.cpp @@ -23,8 +23,6 @@ #include "crypto/hash.h" //#include "serialization/json_archive.h" -using namespace std; -using namespace epee; using namespace cryptonote; DISABLE_VS_WARNINGS(4267) @@ -85,14 +83,14 @@ bool blockchain_storage::init(const std::string& config_folder) uint64_t timestamp_diff = time(NULL) - m_blocks.back().bl.timestamp; if(!m_blocks.back().bl.timestamp) timestamp_diff = time(NULL) - 1341378000; - LOG_PRINT_GREEN("Blockchain initialized. last block: " << m_blocks.size()-1 << ", " << misc_utils::get_time_interval_string(timestamp_diff) << " time ago, current difficulty: " << get_difficulty_for_next_block(), LOG_LEVEL_0); + LOG_PRINT_GREEN("Blockchain initialized. last block: " << m_blocks.size() - 1 << ", " << epee::misc_utils::get_time_interval_string(timestamp_diff) << " time ago, current difficulty: " << get_difficulty_for_next_block(), LOG_LEVEL_0); return true; } //------------------------------------------------------------------ bool blockchain_storage::store_blockchain() { m_is_blockchain_storing = true; - misc_utils::auto_scope_leave_caller scope_exit_handler = misc_utils::create_scope_leave_handler([&](){m_is_blockchain_storing=false;}); + epee::misc_utils::auto_scope_leave_caller scope_exit_handler = epee::misc_utils::create_scope_leave_handler([&](){m_is_blockchain_storing=false;}); LOG_PRINT_L0("Storing blockchain..."); if (!tools::create_directories_if_necessary(m_config_folder)) @@ -517,8 +515,7 @@ bool blockchain_storage::validate_miner_transaction(const block& b, size_t cumul std::vector<size_t> last_blocks_sizes; get_last_n_blocks_sizes(last_blocks_sizes, CRYPTONOTE_REWARD_BLOCKS_WINDOW); - if(!get_block_reward(misc_utils::median(last_blocks_sizes), cumulative_block_size, already_generated_coins, base_reward)) - { + if (!get_block_reward(epee::misc_utils::median(last_blocks_sizes), cumulative_block_size, already_generated_coins, base_reward)) { LOG_PRINT_L0("block size " << cumulative_block_size << " is bigger than allowed for this blockchain"); return false; } @@ -707,7 +704,7 @@ bool blockchain_storage::handle_alternative_block(const block& b, const crypto:: uint64_t block_height = get_block_height(b); if(0 == block_height) { - LOG_ERROR("Block with id: " << string_tools::pod_to_hex(id) << " (as alternative) have wrong miner transaction"); + LOG_ERROR("Block with id: " << epee::string_tools::pod_to_hex(id) << " (as alternative) have wrong miner transaction"); bvc.m_verifivation_failed = true; return false; } @@ -791,7 +788,7 @@ bool blockchain_storage::handle_alternative_block(const block& b, const crypto:: if(!prevalidate_miner_transaction(b, bei.height)) { - LOG_PRINT_RED_L0("Block with id: " << string_tools::pod_to_hex(id) + LOG_PRINT_RED_L0("Block with id: " << epee::string_tools::pod_to_hex(id) << " (as alternative) have wrong miner transaction."); bvc.m_verifivation_failed = true; return false; @@ -1104,7 +1101,7 @@ void blockchain_storage::print_blockchain_outs(const std::string& file) ss << "\t" << vals[i].first << ": " << vals[i].second << ENDL; } } - if(file_io_utils::save_string_to_file(file, ss.str())) + if(epee::file_io_utils::save_string_to_file(file, ss.str())) { LOG_PRINT_L0("Current outputs index writen to file: " << file); }else @@ -1352,7 +1349,7 @@ bool blockchain_storage::check_tx_inputs(const transaction& tx, const crypto::ha if(have_tx_keyimg_as_spent(in_to_key.k_image)) { - LOG_PRINT_L1("Key image already spent in blockchain: " << string_tools::pod_to_hex(in_to_key.k_image)); + LOG_PRINT_L1("Key image already spent in blockchain: " << epee::string_tools::pod_to_hex(in_to_key.k_image)); return false; } @@ -1651,7 +1648,7 @@ bool blockchain_storage::update_next_comulative_size_limit() std::vector<size_t> sz; get_last_n_blocks_sizes(sz, CRYPTONOTE_REWARD_BLOCKS_WINDOW); - uint64_t median = misc_utils::median(sz); + uint64_t median = epee::misc_utils::median(sz); if(median <= CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE) median = CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE; diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp index 2609fc13e..2a0129f4e 100644 --- a/src/cryptonote_core/cryptonote_core.cpp +++ b/src/cryptonote_core/cryptonote_core.cpp @@ -81,24 +81,6 @@ namespace cryptonote return m_blockchain_storage.get_transactions(txs_ids, txs, missed_txs); } //----------------------------------------------------------------------------------------------- - bool core::get_transaction(const crypto::hash &h, transaction &tx) - { - std::vector<crypto::hash> ids; - ids.push_back(h); - std::list<transaction> ltx; - std::list<crypto::hash> missing; - if (m_blockchain_storage.get_transactions(ids, ltx, missing)) - { - if (ltx.size() > 0) - { - tx = *ltx.begin(); - return true; - } - } - - return false; - } - //----------------------------------------------------------------------------------------------- bool core::get_alternative_blocks(std::list<block>& blocks) { return m_blockchain_storage.get_alternative_blocks(blocks); @@ -284,10 +266,10 @@ namespace cryptonote return m_blockchain_storage.get_total_transactions(); } //----------------------------------------------------------------------------------------------- - bool core::get_outs(uint64_t amount, std::list<crypto::public_key>& pkeys) - { - return m_blockchain_storage.get_outs(amount, pkeys); - } + //bool core::get_outs(uint64_t amount, std::list<crypto::public_key>& pkeys) + //{ + // return m_blockchain_storage.get_outs(amount, pkeys); + //} //----------------------------------------------------------------------------------------------- bool core::add_new_tx(const transaction& tx, const crypto::hash& tx_hash, const crypto::hash& tx_prefix_hash, size_t blob_size, tx_verification_context& tvc, bool keeped_by_block) { @@ -398,10 +380,10 @@ namespace cryptonote { m_miner.on_synchronized(); } - bool core::get_backward_blocks_sizes(uint64_t from_height, std::vector<size_t>& sizes, size_t count) - { - return m_blockchain_storage.get_backward_blocks_sizes(from_height, sizes, count); - } + //bool core::get_backward_blocks_sizes(uint64_t from_height, std::vector<size_t>& sizes, size_t count) + //{ + // return m_blockchain_storage.get_backward_blocks_sizes(from_height, sizes, count); + //} //----------------------------------------------------------------------------------------------- bool core::add_new_block(const block& b, block_verification_context& bvc) { @@ -418,7 +400,6 @@ namespace cryptonote return false; } - block b = AUTO_VAL_INIT(b); if(!parse_and_validate_block_from_blob(block_blob, b)) { @@ -493,9 +474,9 @@ namespace cryptonote return m_blockchain_storage.get_block_by_hash(h, blk); } //----------------------------------------------------------------------------------------------- - void core::get_all_known_block_ids(std::list<crypto::hash> &main, std::list<crypto::hash> &alt, std::list<crypto::hash> &invalid) { - m_blockchain_storage.get_all_known_block_ids(main, alt, invalid); - } + //void core::get_all_known_block_ids(std::list<crypto::hash> &main, std::list<crypto::hash> &alt, std::list<crypto::hash> &invalid) { + // m_blockchain_storage.get_all_known_block_ids(main, alt, invalid); + //} //----------------------------------------------------------------------------------------------- std::string core::print_pool(bool short_format) { diff --git a/src/cryptonote_core/cryptonote_core.h b/src/cryptonote_core/cryptonote_core.h index 1f1b6eec6..660fcf349 100644 --- a/src/cryptonote_core/cryptonote_core.h +++ b/src/cryptonote_core/cryptonote_core.h @@ -58,9 +58,8 @@ namespace cryptonote } crypto::hash get_block_id_by_height(uint64_t height); bool get_transactions(const std::vector<crypto::hash>& txs_ids, std::list<transaction>& txs, std::list<crypto::hash>& missed_txs); - bool get_transaction(const crypto::hash &h, transaction &tx); bool get_block_by_hash(const crypto::hash &h, block &blk); - void get_all_known_block_ids(std::list<crypto::hash> &main, std::list<crypto::hash> &alt, std::list<crypto::hash> &invalid); + //void get_all_known_block_ids(std::list<crypto::hash> &main, std::list<crypto::hash> &alt, std::list<crypto::hash> &invalid); bool get_alternative_blocks(std::list<block>& blocks); size_t get_alternative_blocks_count(); @@ -71,13 +70,13 @@ namespace cryptonote bool get_pool_transactions(std::list<transaction>& txs); size_t get_pool_transactions_count(); size_t get_blockchain_total_transactions(); - bool get_outs(uint64_t amount, std::list<crypto::public_key>& pkeys); + //bool get_outs(uint64_t amount, std::list<crypto::public_key>& pkeys); bool have_block(const crypto::hash& id); bool get_short_chain_history(std::list<crypto::hash>& ids); bool find_blockchain_supplement(const std::list<crypto::hash>& qblock_ids, NOTIFY_RESPONSE_CHAIN_ENTRY::request& resp); bool find_blockchain_supplement(const std::list<crypto::hash>& qblock_ids, std::list<std::pair<block, std::list<transaction> > >& blocks, uint64_t& total_height, uint64_t& start_height, size_t max_count); bool get_stat_info(core_stat_info& st_inf); - bool get_backward_blocks_sizes(uint64_t from_height, std::vector<size_t>& sizes, size_t count); + //bool get_backward_blocks_sizes(uint64_t from_height, std::vector<size_t>& sizes, size_t count); bool get_tx_outputs_gindexs(const crypto::hash& tx_id, std::vector<uint64_t>& indexs); crypto::hash get_tail_id(); bool get_random_outs_for_amounts(const COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS::request& req, COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS::response& res); diff --git a/src/cryptonote_core/cryptonote_format_utils.cpp b/src/cryptonote_core/cryptonote_format_utils.cpp index 7b7f18844..c5691d8fe 100644 --- a/src/cryptonote_core/cryptonote_format_utils.cpp +++ b/src/cryptonote_core/cryptonote_format_utils.cpp @@ -595,7 +595,7 @@ namespace cryptonote { blobdata blob = t_serializable_object_to_blob(static_cast<block_header>(b)); crypto::hash tree_root_hash = get_tx_tree_hash(b); - blob.append((const char*)&tree_root_hash, sizeof(tree_root_hash )); + blob.append(reinterpret_cast<const char*>(&tree_root_hash), sizeof(tree_root_hash)); blob.append(tools::get_varint_data(b.tx_hashes.size()+1)); return blob; } diff --git a/src/cryptonote_core/cryptonote_format_utils.h b/src/cryptonote_core/cryptonote_format_utils.h index 138fb5224..81d804298 100644 --- a/src/cryptonote_core/cryptonote_format_utils.h +++ b/src/cryptonote_core/cryptonote_format_utils.h @@ -85,7 +85,6 @@ namespace cryptonote uint64_t get_outs_money_amount(const transaction& tx); bool check_inputs_types_supported(const transaction& tx); bool check_outs_valid(const transaction& tx); - blobdata get_block_hashing_blob(const block& b); bool parse_amount(uint64_t& amount, const std::string& str_amount); bool check_money_overflow(const transaction& tx); diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl index 16140cf35..fd1f57658 100644 --- a/src/p2p/net_node.inl +++ b/src/p2p/net_node.inl @@ -130,7 +130,7 @@ namespace nodetool if (!parse_peers_and_add_to_container(vm, arg_p2p_add_exclusive_node, m_exclusive_peers)) return false; } - else if (command_line::has_arg(vm, arg_p2p_add_priority_node)) + if (command_line::has_arg(vm, arg_p2p_add_priority_node)) { if (!parse_peers_and_add_to_container(vm, arg_p2p_add_priority_node, m_priority_peers)) return false; diff --git a/src/rpc/core_rpc_server_commands_defs.h b/src/rpc/core_rpc_server_commands_defs.h index 6e87fb48c..20f73c9d8 100644 --- a/src/rpc/core_rpc_server_commands_defs.h +++ b/src/rpc/core_rpc_server_commands_defs.h @@ -115,8 +115,8 @@ namespace cryptonote { struct request { - std::list<uint64_t> amounts; - uint64_t outs_count; + std::vector<uint64_t> amounts; + uint64_t outs_count; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(amounts) KV_SERIALIZE(outs_count) @@ -414,7 +414,11 @@ namespace cryptonote struct COMMAND_RPC_GET_LAST_BLOCK_HEADER { - typedef std::list<std::string> request; + struct request + { + BEGIN_KV_SERIALIZE_MAP() + END_KV_SERIALIZE_MAP() + }; struct response { diff --git a/src/serialization/binary_utils.h b/src/serialization/binary_utils.h index d06e8a22a..00bb1741d 100644 --- a/src/serialization/binary_utils.h +++ b/src/serialization/binary_utils.h @@ -2,6 +2,8 @@ // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. +#pragma once + #include <sstream> #include "binary_archive.h" diff --git a/src/serialization/crypto.h b/src/serialization/crypto.h index b7763ffeb..6e683e629 100644 --- a/src/serialization/crypto.h +++ b/src/serialization/crypto.h @@ -2,6 +2,8 @@ // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. +#pragma once + #include <vector> #include "serialization.h" diff --git a/src/serialization/json_utils.h b/src/serialization/json_utils.h index 35bcc0335..24f5c11a8 100644 --- a/src/serialization/json_utils.h +++ b/src/serialization/json_utils.h @@ -2,6 +2,8 @@ // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. +#pragma once + #include <sstream> #include "json_archive.h" diff --git a/src/serialization/vector.h b/src/serialization/vector.h index 9a0c0ee56..d07472352 100644 --- a/src/serialization/vector.h +++ b/src/serialization/vector.h @@ -17,6 +17,13 @@ namespace serialization } template <typename Archive> + bool serialize_vector_element(Archive& ar, uint32_t& e) + { + ar.serialize_varint(e); + return true; + } + + template <typename Archive> bool serialize_vector_element(Archive& ar, uint64_t& e) { ar.serialize_varint(e); diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index 8ceb583be..cbd682e78 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -499,9 +499,9 @@ bool simple_wallet::start_mining(const std::vector<std::string>& args) } else if (1 == args.size()) { - uint16_t num; + uint16_t num = 1; ok = string_tools::get_xtype_from_string(num, args[0]); - ok &= (1 <= num && num <= max_mining_threads_count); + ok = ok && (1 <= num && num <= max_mining_threads_count); req.threads_count = num; } else diff --git a/src/wallet/wallet_errors.h b/src/wallet/wallet_errors.h index 71c946545..e25d064c5 100644 --- a/src/wallet/wallet_errors.h +++ b/src/wallet/wallet_errors.h @@ -203,7 +203,7 @@ namespace tools struct refresh_error : public wallet_logic_error { protected: - refresh_error(std::string&& loc, const std::string& message) + explicit refresh_error(std::string&& loc, const std::string& message) : wallet_logic_error(std::move(loc), message) { } @@ -277,7 +277,7 @@ namespace tools struct transfer_error : public wallet_logic_error { protected: - transfer_error(std::string&& loc, const std::string& message) + explicit transfer_error(std::string&& loc, const std::string& message) : wallet_logic_error(std::move(loc), message) { } @@ -287,7 +287,7 @@ namespace tools //---------------------------------------------------------------------------------------------------- struct not_enough_money : public transfer_error { - not_enough_money(std::string&& loc, uint64_t availbable, uint64_t tx_amount, uint64_t fee) + explicit not_enough_money(std::string&& loc, uint64_t availbable, uint64_t tx_amount, uint64_t fee) : transfer_error(std::move(loc), "not enough money") , m_available(availbable) , m_tx_amount(tx_amount) @@ -431,7 +431,7 @@ namespace tools //---------------------------------------------------------------------------------------------------- struct tx_sum_overflow : public transfer_error { - tx_sum_overflow(std::string&& loc, const std::vector<cryptonote::tx_destination_entry>& destinations, uint64_t fee) + explicit tx_sum_overflow(std::string&& loc, const std::vector<cryptonote::tx_destination_entry>& destinations, uint64_t fee) : transfer_error(std::move(loc), "transaction sum + fee exceeds " + cryptonote::print_money(std::numeric_limits<uint64_t>::max())) , m_destinations(destinations) , m_fee(fee) @@ -507,7 +507,7 @@ namespace tools } protected: - wallet_rpc_error(std::string&& loc, const std::string& message, const std::string& request) + explicit wallet_rpc_error(std::string&& loc, const std::string& message, const std::string& request) : wallet_logic_error(std::move(loc), message) , m_request(request) { |