diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/blockchain_db/lmdb/db_lmdb.cpp | 144 | ||||
-rw-r--r-- | src/blockchain_utilities/blockchain_export.cpp | 71 | ||||
-rw-r--r-- | src/blockchain_utilities/bootstrap_file.h | 2 | ||||
-rw-r--r-- | src/cryptonote_core/blockchain.cpp | 2 | ||||
-rw-r--r-- | src/version.cmake | 2 | ||||
-rw-r--r-- | src/wallet/wallet_rpc_server.cpp | 25 |
6 files changed, 140 insertions, 106 deletions
diff --git a/src/blockchain_db/lmdb/db_lmdb.cpp b/src/blockchain_db/lmdb/db_lmdb.cpp index 01a36a8da..8955072b5 100644 --- a/src/blockchain_db/lmdb/db_lmdb.cpp +++ b/src/blockchain_db/lmdb/db_lmdb.cpp @@ -65,45 +65,6 @@ inline void throw1(const T &e) throw e; } -// cursor needs to be closed when it goes out of scope, -// this helps if the function using it throws -struct lmdb_cur -{ - lmdb_cur(MDB_txn* txn, MDB_dbi dbi) - { - if (mdb_cursor_open(txn, dbi, &m_cur)) - throw0(cryptonote::DB_ERROR("Error opening db cursor")); - done = false; - } - - ~lmdb_cur() - { - close(); - } - - operator MDB_cursor*() - { - return m_cur; - } - operator MDB_cursor**() - { - return &m_cur; - } - - void close() - { - if (!done) - { - mdb_cursor_close(m_cur); - done = true; - } - } - -private: - MDB_cursor* m_cur; - bool done; -}; - template<typename T> struct MDB_val_copy: public MDB_val { @@ -149,8 +110,14 @@ private: int compare_uint64(const MDB_val *a, const MDB_val *b) { +#ifdef MISALIGNED_OK const uint64_t va = *(const uint64_t*)a->mv_data; const uint64_t vb = *(const uint64_t*)b->mv_data; +#else + uint64_t va, vb; + memcpy(&va, a->mv_data, sizeof(uint64_t)); + memcpy(&vb, b->mv_data, sizeof(uint64_t)); +#endif if (va < vb) return -1; else if (va == vb) return 0; else return 1; @@ -208,11 +175,6 @@ const char* const LMDB_HF_VERSIONS = "hf_versions"; const char* const LMDB_PROPERTIES = "properties"; -inline void lmdb_db_open(MDB_txn* txn, const char* name, int flags, MDB_dbi& dbi, const std::string& error_string) -{ - if (mdb_dbi_open(txn, name, flags, &dbi)) - throw0(cryptonote::DB_OPEN_FAILURE(error_string.c_str())); -} const std::string lmdb_error(const std::string& error_string, int mdb_res) { @@ -220,20 +182,27 @@ const std::string lmdb_error(const std::string& error_string, int mdb_res) return full_string; } +inline void lmdb_db_open(MDB_txn* txn, const char* name, int flags, MDB_dbi& dbi, const std::string& error_string) +{ + if (auto res = mdb_dbi_open(txn, name, flags, &dbi)) + throw0(cryptonote::DB_OPEN_FAILURE(lmdb_error(error_string + " : ", res).c_str())); +} + + } // anonymous namespace #define CURSOR(name) \ if (!m_cur_ ## name) { \ int result = mdb_cursor_open(*m_write_txn, m_ ## name, &m_cur_ ## name); \ if (result) \ - throw0(DB_ERROR(std::string("Failed to open cursor: ").append(mdb_strerror(result)).c_str())); \ + throw0(DB_ERROR(lmdb_error("Failed to open cursor: ", result).c_str())); \ } #define RCURSOR(name) \ if (!m_cur_ ## name) { \ int result = mdb_cursor_open(m_txn, m_ ## name, (MDB_cursor **)&m_cur_ ## name); \ if (result) \ - throw0(DB_ERROR(std::string("Failed to open cursor: ").append(mdb_strerror(result)).c_str())); \ + throw0(DB_ERROR(lmdb_error("Failed to open cursor: ", result).c_str())); \ if (!m_write_txn) \ m_tinfo->m_ti_rflags.m_rf_ ## name = true; \ } else if (!m_write_txn && !m_tinfo->m_ti_rflags.m_rf_ ## name) { \ @@ -298,7 +267,7 @@ void mdb_txn_safe::commit(std::string message) if (auto result = mdb_txn_commit(m_txn)) { m_txn = nullptr; - throw0(DB_ERROR((message + ": ").append(mdb_strerror(result)).c_str())); + throw0(DB_ERROR(lmdb_error(message + ": ", result).c_str())); } m_txn = nullptr; } @@ -590,35 +559,35 @@ void BlockchainLMDB::add_block(const block& blk, const size_t& block_size, const MDB_val_copy<blobdata> blob(block_to_blob(blk)); result = mdb_cursor_put(m_cur_blocks, &key, &blob, MDB_APPEND); if (result) - throw0(DB_ERROR(std::string("Failed to add block blob to db transaction: ").append(mdb_strerror(result)).c_str())); + throw0(DB_ERROR(lmdb_error("Failed to add block blob to db transaction: ", result).c_str())); MDB_val_copy<size_t> sz(block_size); result = mdb_cursor_put(m_cur_block_sizes, &key, &sz, MDB_APPEND); if (result) - throw0(DB_ERROR(std::string("Failed to add block size to db transaction: ").append(mdb_strerror(result)).c_str())); + throw0(DB_ERROR(lmdb_error("Failed to add block size to db transaction: ", result).c_str())); MDB_val_copy<uint64_t> ts(blk.timestamp); result = mdb_cursor_put(m_cur_block_timestamps, &key, &ts, MDB_APPEND); if (result) - throw0(DB_ERROR(std::string("Failed to add block timestamp to db transaction: ").append(mdb_strerror(result)).c_str())); + throw0(DB_ERROR(lmdb_error("Failed to add block timestamp to db transaction: ", result).c_str())); MDB_val_copy<difficulty_type> diff(cumulative_difficulty); result = mdb_cursor_put(m_cur_block_diffs, &key, &diff, MDB_APPEND); if (result) - throw0(DB_ERROR(std::string("Failed to add block cumulative difficulty to db transaction: ").append(mdb_strerror(result)).c_str())); + throw0(DB_ERROR(lmdb_error("Failed to add block cumulative difficulty to db transaction: ", result).c_str())); MDB_val_copy<uint64_t> coinsgen(coins_generated); result = mdb_cursor_put(m_cur_block_coins, &key, &coinsgen, MDB_APPEND); if (result) - throw0(DB_ERROR(std::string("Failed to add block total generated coins to db transaction: ").append(mdb_strerror(result)).c_str())); + throw0(DB_ERROR(lmdb_error("Failed to add block total generated coins to db transaction: ", result).c_str())); result = mdb_cursor_put(m_cur_block_heights, &val_h, &key, 0); if (result) - throw0(DB_ERROR(std::string("Failed to add block height by hash to db transaction: ").append(mdb_strerror(result)).c_str())); + throw0(DB_ERROR(lmdb_error("Failed to add block height by hash to db transaction: ", result).c_str())); result = mdb_cursor_put(m_cur_block_hashes, &key, &val_h, MDB_APPEND); if (result) - throw0(DB_ERROR(std::string("Failed to add block hash to db transaction: ").append(mdb_strerror(result)).c_str())); + throw0(DB_ERROR(lmdb_error("Failed to add block hash to db transaction: ", result).c_str())); m_cum_size += block_size; m_cum_count++; @@ -679,17 +648,17 @@ void BlockchainLMDB::add_transaction_data(const crypto::hash& blk_hash, const tr MDB_val_copy<blobdata> blob(tx_to_blob(tx)); result = mdb_cursor_put(m_cur_txs, &val_h, &blob, 0); if (result) - throw0(DB_ERROR(std::string("Failed to add tx blob to db transaction: ").append(mdb_strerror(result)).c_str())); + throw0(DB_ERROR(lmdb_error("Failed to add tx blob to db transaction: ", result).c_str())); MDB_val_copy<uint64_t> height(m_height); result = mdb_cursor_put(m_cur_tx_heights, &val_h, &height, 0); if (result) - throw0(DB_ERROR(std::string("Failed to add tx block height to db transaction: ").append(mdb_strerror(result)).c_str())); + throw0(DB_ERROR(lmdb_error("Failed to add tx block height to db transaction: ", result).c_str())); MDB_val_copy<uint64_t> unlock_time(tx.unlock_time); result = mdb_cursor_put(m_cur_tx_unlocks, &val_h, &unlock_time, 0); if (result) - throw0(DB_ERROR(std::string("Failed to add tx unlock time to db transaction: ").append(mdb_strerror(result)).c_str())); + throw0(DB_ERROR(lmdb_error("Failed to add tx unlock time to db transaction: ", result).c_str())); } void BlockchainLMDB::remove_transaction_data(const crypto::hash& tx_hash, const transaction& tx) @@ -715,7 +684,7 @@ void BlockchainLMDB::remove_transaction_data(const crypto::hash& tx_hash, const if (result == MDB_NOTFOUND) LOG_PRINT_L1("tx has no outputs to remove: " << tx_hash); else if (result) - throw1(DB_ERROR(std::string("Failed to add removal of tx outputs to db transaction: ").append(mdb_strerror(result)).c_str())); + throw1(DB_ERROR(lmdb_error("Failed to add removal of tx outputs to db transaction: ", result).c_str())); } void BlockchainLMDB::add_output(const crypto::hash& tx_hash, const tx_out& tx_output, const uint64_t& local_index, const uint64_t unlock_time) @@ -737,20 +706,20 @@ void BlockchainLMDB::add_output(const crypto::hash& tx_hash, const tx_out& tx_ou result = mdb_cursor_put(m_cur_output_txs, &k, &v, MDB_APPEND); if (result) - throw0(DB_ERROR(std::string("Failed to add output tx hash to db transaction: ").append(mdb_strerror(result)).c_str())); + throw0(DB_ERROR(lmdb_error("Failed to add output tx hash to db transaction: ", result).c_str())); result = mdb_cursor_put(m_cur_tx_outputs, &v, &k, 0); if (result) - throw0(DB_ERROR(std::string("Failed to add <tx hash, global output index> to db transaction: ").append(mdb_strerror(result)).c_str())); + throw0(DB_ERROR(lmdb_error("Failed to add <tx hash, global output index> to db transaction: ", result).c_str())); MDB_val_copy<uint64_t> val_local_index(local_index); result = mdb_cursor_put(m_cur_output_indices, &k, &val_local_index, MDB_APPEND); if (result) - throw0(DB_ERROR(std::string("Failed to add tx output index to db transaction: ").append(mdb_strerror(result)).c_str())); + throw0(DB_ERROR(lmdb_error("Failed to add tx output index to db transaction: ", result).c_str())); MDB_val_copy<uint64_t> val_amount(tx_output.amount); result = mdb_cursor_put(m_cur_output_amounts, &val_amount, &k, 0); if (result) - throw0(DB_ERROR(std::string("Failed to add output amount to db transaction: ").append(mdb_strerror(result)).c_str())); + throw0(DB_ERROR(lmdb_error("Failed to add output amount to db transaction: ", result).c_str())); if (tx_output.target.type() == typeid(txout_to_key)) { @@ -776,12 +745,12 @@ void BlockchainLMDB::remove_tx_outputs(const crypto::hash& tx_hash, const transa { LOG_PRINT_L3("BlockchainLMDB::" << __func__); - lmdb_cur cur(*m_write_txn, m_tx_outputs); - + mdb_txn_cursors *m_cursors = &m_wcursors; MDB_val_copy<crypto::hash> k(tx_hash); MDB_val v; + CURSOR(tx_outputs) - auto result = mdb_cursor_get(cur, &k, &v, MDB_SET); + auto result = mdb_cursor_get(m_cur_tx_outputs, &k, &v, MDB_SET); if (result == MDB_NOTFOUND) { LOG_PRINT_L2("tx has no outputs, so no global output indices"); @@ -793,9 +762,9 @@ void BlockchainLMDB::remove_tx_outputs(const crypto::hash& tx_hash, const transa else { mdb_size_t num_elems = 0; - mdb_cursor_count(cur, &num_elems); + mdb_cursor_count(m_cur_tx_outputs, &num_elems); - mdb_cursor_get(cur, &k, &v, MDB_LAST_DUP); + mdb_cursor_get(m_cur_tx_outputs, &k, &v, MDB_LAST_DUP); for (uint64_t i = num_elems; i > 0; --i) { @@ -803,12 +772,10 @@ void BlockchainLMDB::remove_tx_outputs(const crypto::hash& tx_hash, const transa remove_output(*(const uint64_t*)v.mv_data, tx_output.amount); if (i > 1) { - mdb_cursor_get(cur, &k, &v, MDB_PREV_DUP); + mdb_cursor_get(m_cur_tx_outputs, &k, &v, MDB_PREV_DUP); } } } - - cur.close(); } // TODO: probably remove this function @@ -864,29 +831,29 @@ void BlockchainLMDB::remove_amount_output_index(const uint64_t amount, const uin { LOG_PRINT_L3("BlockchainLMDB::" << __func__); check_open(); - - lmdb_cur cur(*m_write_txn, m_output_amounts); + mdb_txn_cursors *m_cursors = &m_wcursors; + CURSOR(output_amounts); MDB_val_copy<uint64_t> k(amount); MDB_val v; - auto result = mdb_cursor_get(cur, &k, &v, MDB_SET); + auto result = mdb_cursor_get(m_cur_output_amounts, &k, &v, MDB_SET); if (result == MDB_NOTFOUND) throw1(OUTPUT_DNE("Attempting to get an output index by amount and amount index, but amount not found")); else if (result) throw0(DB_ERROR("DB error attempting to get an output")); mdb_size_t num_elems = 0; - mdb_cursor_count(cur, &num_elems); + mdb_cursor_count(m_cur_output_amounts, &num_elems); - mdb_cursor_get(cur, &k, &v, MDB_LAST_DUP); + mdb_cursor_get(m_cur_output_amounts, &k, &v, MDB_LAST_DUP); uint64_t amount_output_index = 0; uint64_t goi = 0; bool found_index = false; for (uint64_t i = num_elems; i > 0; --i) { - mdb_cursor_get(cur, &k, &v, MDB_GET_CURRENT); + mdb_cursor_get(m_cur_output_amounts, &k, &v, MDB_GET_CURRENT); goi = *(const uint64_t *)v.mv_data; if (goi == global_output_index) { @@ -895,23 +862,21 @@ void BlockchainLMDB::remove_amount_output_index(const uint64_t amount, const uin break; } if (i > 1) - mdb_cursor_get(cur, &k, &v, MDB_PREV_DUP); + mdb_cursor_get(m_cur_output_amounts, &k, &v, MDB_PREV_DUP); } if (found_index) { // found the amount output index // now delete it - result = mdb_cursor_del(cur, 0); + result = mdb_cursor_del(m_cur_output_amounts, 0); if (result) throw0(DB_ERROR(std::string("Error deleting amount output index ").append(boost::lexical_cast<std::string>(amount_output_index)).c_str())); } else { // not found - cur.close(); throw1(OUTPUT_DNE("Failed to find amount output index")); } - cur.close(); } void BlockchainLMDB::add_spent_key(const crypto::key_image& k_image) @@ -931,7 +896,7 @@ void BlockchainLMDB::add_spent_key(const crypto::key_image& k_image) unused.mv_size = sizeof(char); unused.mv_data = &anything; if (auto result = mdb_cursor_put(m_cur_spent_keys, &val_key, &unused, 0)) - throw1(DB_ERROR(std::string("Error adding spent key image to db transaction: ").append(mdb_strerror(result)).c_str())); + throw1(DB_ERROR(lmdb_error("Error adding spent key image to db transaction: ", result).c_str())); } void BlockchainLMDB::remove_spent_key(const crypto::key_image& k_image) @@ -1057,7 +1022,7 @@ void BlockchainLMDB::open(const std::string& filename, const int mdb_flags) size_t mapsize = DEFAULT_MAPSIZE; if (auto result = mdb_env_open(m_env, filename.c_str(), mdb_flags, 0644)) - throw0(DB_ERROR(std::string("Failed to open lmdb environment: ").append(mdb_strerror(result)).c_str())); + throw0(DB_ERROR(lmdb_error("Failed to open lmdb environment: ", result).c_str())); MDB_envinfo mei; mdb_env_info(m_env, &mei); @@ -1066,7 +1031,7 @@ void BlockchainLMDB::open(const std::string& filename, const int mdb_flags) if (cur_mapsize < mapsize) { if (auto result = mdb_env_set_mapsize(m_env, mapsize)) - throw0(DB_ERROR(std::string("Failed to set max memory map size: ").append(mdb_strerror(result)).c_str())); + throw0(DB_ERROR(lmdb_error("Failed to set max memory map size: ", result).c_str())); mdb_env_info(m_env, &mei); cur_mapsize = (double)mei.me_mapsize; LOG_PRINT_L1("LMDB memory map size: " << cur_mapsize); @@ -1246,7 +1211,7 @@ void BlockchainLMDB::sync() // MDB_NOMETASYNC. Force flush to be synchronous. if (auto result = mdb_env_sync(m_env, true)) { - throw0(DB_ERROR(std::string("Failed to sync database: ").append(mdb_strerror(result)).c_str())); + throw0(DB_ERROR(lmdb_error("Failed to sync database: ", result).c_str())); } } @@ -1609,8 +1574,7 @@ crypto::hash BlockchainLMDB::get_block_hash_from_height(const uint64_t& height) throw0(BLOCK_DNE(std::string("Attempt to get hash from height ").append(boost::lexical_cast<std::string>(height)).append(" failed -- hash not in db").c_str())); } else if (get_result) - throw0(DB_ERROR(std::string("Error attempting to retrieve a block hash from the db: "). - append(mdb_strerror(get_result)).c_str())); + throw0(DB_ERROR(lmdb_error("Error attempting to retrieve a block hash from the db: ", get_result).c_str())); crypto::hash ret = *(const crypto::hash*)result.mv_data; TXN_POSTFIX_RDONLY(); @@ -2771,7 +2735,7 @@ void BlockchainLMDB::set_hard_fork_starting_height(uint8_t version, uint64_t hei MDB_val_copy<uint8_t> val_key(version); MDB_val_copy<uint64_t> val_value(height); if (auto result = mdb_put(*txn_ptr, m_hf_starting_heights, &val_key, &val_value, MDB_APPEND)) - throw1(DB_ERROR(std::string("Error adding hard fork starting height to db transaction: ").append(mdb_strerror(result)).c_str())); + throw1(DB_ERROR(lmdb_error("Error adding hard fork starting height to db transaction: ", result).c_str())); TXN_BLOCK_POSTFIX_SUCCESS(); } @@ -2815,7 +2779,7 @@ void BlockchainLMDB::set_hard_fork_version(uint64_t height, uint8_t version) if (result == MDB_KEYEXIST) result = mdb_put(*txn_ptr, m_hf_versions, &val_key, &val_value, 0); if (result) - throw1(DB_ERROR(std::string("Error adding hard fork version to db transaction: ").append(mdb_strerror(result)).c_str())); + throw1(DB_ERROR(lmdb_error("Error adding hard fork version to db transaction: ", result).c_str())); TXN_BLOCK_POSTFIX_SUCCESS(); } @@ -2833,7 +2797,7 @@ uint8_t BlockchainLMDB::get_hard_fork_version(uint64_t height) const MDB_val val_ret; auto result = mdb_cursor_get(m_cur_hf_versions, &val_key, &val_ret, MDB_SET); if (result == MDB_NOTFOUND || result) - throw0(DB_ERROR(std::string("Error attempting to retrieve a hard fork version at height ").append(boost::lexical_cast<std::string>(height)).append(" from the db: ").append(mdb_strerror(result)).c_str())); + throw0(DB_ERROR(lmdb_error("Error attempting to retrieve a hard fork version at height " + boost::lexical_cast<std::string>(height) + " from the db: ", result).c_str())); uint8_t ret = *(const uint8_t*)val_ret.mv_data; TXN_POSTFIX_RDONLY(); @@ -2845,7 +2809,7 @@ bool BlockchainLMDB::is_read_only() const unsigned int flags; auto result = mdb_env_get_flags(m_env, &flags); if (result) - throw0(DB_ERROR(std::string("Error getting database environment info: ").append(mdb_strerror(result)).c_str())); + throw0(DB_ERROR(lmdb_error("Error getting database environment info: ", result).c_str())); if (flags & MDB_RDONLY) return true; diff --git a/src/blockchain_utilities/blockchain_export.cpp b/src/blockchain_utilities/blockchain_export.cpp index d90175a77..964c610cd 100644 --- a/src/blockchain_utilities/blockchain_export.cpp +++ b/src/blockchain_utilities/blockchain_export.cpp @@ -29,13 +29,42 @@ #include "bootstrap_file.h" #include "blocksdat_file.h" #include "common/command_line.h" +#include "blockchain_db/blockchain_db.h" +#include "blockchain_db/lmdb/db_lmdb.h" +#if defined(BERKELEY_DB) +#include "blockchain_db/berkeleydb/db_bdb.h" +#endif +#include "blockchain_db/db_types.h" #include "version.h" namespace po = boost::program_options; using namespace epee; // log_space +std::string join_set_strings(const std::unordered_set<std::string>& db_types_all, const char* delim) +{ + std::string result; + std::ostringstream s; + std::copy(db_types_all.begin(), db_types_all.end(), std::ostream_iterator<std::string>(s, delim)); + result = s.str(); + if (result.length() > 0) + result.erase(result.end()-strlen(delim), result.end()); + return result; +} + int main(int argc, char* argv[]) { +#if defined(BLOCKCHAIN_DB) && (BLOCKCHAIN_DB == DB_MEMORY) + std::string default_db_type = "memory"; +#else + std::string default_db_type = "lmdb"; +#endif + + std::unordered_set<std::string> db_types_all = cryptonote::blockchain_db_types; + db_types_all.insert("memory"); + + std::string available_dbs = join_set_strings(db_types_all, ", "); + available_dbs = "available: " + available_dbs; + uint32_t log_level = 0; uint64_t block_stop = 0; bool blocks_dat = false; @@ -56,6 +85,9 @@ int main(int argc, char* argv[]) , "Run on testnet." , false }; + const command_line::arg_descriptor<std::string> arg_database = { + "database", available_dbs.c_str(), default_db_type + }; const command_line::arg_descriptor<bool> arg_blocks_dat = {"blocksdat", "Output in blocks.dat format", blocks_dat}; @@ -64,6 +96,7 @@ int main(int argc, char* argv[]) command_line::add_arg(desc_cmd_sett, arg_output_file); 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_database); command_line::add_arg(desc_cmd_sett, arg_block_stop); command_line::add_arg(desc_cmd_sett, arg_blocks_dat); @@ -105,6 +138,20 @@ int main(int argc, char* argv[]) 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); + std::string db_type = command_line::get_arg(vm, arg_database); + if (db_types_all.count(db_type) == 0) + { + std::cerr << "Invalid database type: " << db_type << std::endl; + return 1; + } +#if !defined(BERKELEY_DB) + if (db_type == "berkeley") + { + LOG_ERROR("BerkeleyDB support disabled."); + return false; + } +#endif + if (command_line::has_arg(vm, arg_output_file)) output_file_path = boost::filesystem::path(command_line::get_arg(vm, arg_output_file)); else @@ -136,17 +183,33 @@ int main(int argc, char* argv[]) tx_memory_pool m_mempool(*core_storage); core_storage = new Blockchain(m_mempool); - BlockchainDB* db = new BlockchainLMDB(); + int db_flags = 0; + + BlockchainDB* db = nullptr; + if (db_type == "lmdb") + { + db_flags |= MDB_RDONLY; + db = new BlockchainLMDB(); + } +#if defined(BERKELEY_DB) + else if (db_type == "berkeley") + db = new BlockchainBDB(); +#endif + else + { + LOG_ERROR("Attempted to use non-existent database type: " << db_type); + throw std::runtime_error("Attempting to use non-existent database type"); + } + LOG_PRINT_L0("database: " << db_type); + boost::filesystem::path folder(m_config_folder); folder /= db->get_db_name(); - int lmdb_flags = 0; - lmdb_flags |= MDB_RDONLY; const std::string filename = folder.string(); LOG_PRINT_L0("Loading blockchain from folder " << filename << " ..."); try { - db->open(filename, lmdb_flags); + db->open(filename, db_flags); } catch (const std::exception& e) { diff --git a/src/blockchain_utilities/bootstrap_file.h b/src/blockchain_utilities/bootstrap_file.h index 1e1c66ba9..dd134f7ae 100644 --- a/src/blockchain_utilities/bootstrap_file.h +++ b/src/blockchain_utilities/bootstrap_file.h @@ -37,8 +37,6 @@ #include "cryptonote_core/cryptonote_basic.h" #include "cryptonote_core/blockchain_storage.h" #include "cryptonote_core/blockchain.h" -#include "blockchain_db/blockchain_db.h" -#include "blockchain_db/lmdb/db_lmdb.h" #include <algorithm> #include <cstdio> diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index a83f4bc9c..2aa8ecec4 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -101,7 +101,7 @@ static const uint64_t testnet_hard_fork_version_1_till = 624633; //------------------------------------------------------------------ Blockchain::Blockchain(tx_memory_pool& tx_pool) : m_db(), m_tx_pool(tx_pool), m_hardfork(NULL), m_timestamps_and_difficulties_height(0), m_current_block_cumul_sz_limit(0), m_is_in_checkpoint_zone(false), - m_is_blockchain_storing(false), m_enforce_dns_checkpoints(false), m_max_prepare_blocks_threads(4), m_db_blocks_per_sync(1), m_db_sync_mode(db_async), m_fast_sync(true), m_sync_counter(0) + m_is_blockchain_storing(false), m_enforce_dns_checkpoints(false), m_max_prepare_blocks_threads(4), m_db_blocks_per_sync(1), m_db_sync_mode(db_async), m_fast_sync(true), m_show_time_stats(false), m_sync_counter(0) { LOG_PRINT_L3("Blockchain::" << __func__); } diff --git a/src/version.cmake b/src/version.cmake index 4cbaa58e2..8c56b392c 100644 --- a/src/version.cmake +++ b/src/version.cmake @@ -72,7 +72,7 @@ else() message(STATUS "You are building a tagged release") set(VERSIONTAG "release") else() - message(STATUS "You are ahead or behind of a tagged release") + message(STATUS "You are ahead of or behind a tagged release") set(VERSIONTAG "${COMMIT}") endif() endif() diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp index e8e062e95..ac13d8021 100644 --- a/src/wallet/wallet_rpc_server.cpp +++ b/src/wallet/wallet_rpc_server.cpp @@ -461,6 +461,7 @@ namespace tools bool wallet_rpc_server::on_get_payments(const wallet_rpc::COMMAND_RPC_GET_PAYMENTS::request& req, wallet_rpc::COMMAND_RPC_GET_PAYMENTS::response& res, epee::json_rpc::error& er) { crypto::hash payment_id; + crypto::hash8 payment_id8; cryptonote::blobdata payment_id_blob; if(!epee::string_tools::parse_hexstr_to_binbuff(req.payment_id, payment_id_blob)) { @@ -469,14 +470,22 @@ namespace tools return false; } - if(sizeof(payment_id) != payment_id_blob.size()) - { - er.code = WALLET_RPC_ERROR_CODE_WRONG_PAYMENT_ID; - er.message = "Payment ID has invalid size"; - return false; - } - - payment_id = *reinterpret_cast<const crypto::hash*>(payment_id_blob.data()); + if(sizeof(payment_id) == payment_id_blob.size()) + { + payment_id = *reinterpret_cast<const crypto::hash*>(payment_id_blob.data()); + } + else if(sizeof(payment_id8) == payment_id_blob.size()) + { + payment_id8 = *reinterpret_cast<const crypto::hash8*>(payment_id_blob.data()); + memcpy(payment_id.data, payment_id8.data, 8); + memset(payment_id.data + 8, 0, 24); + } + else + { + er.code = WALLET_RPC_ERROR_CODE_WRONG_PAYMENT_ID; + er.message = "Payment ID has invalid size: " + req.payment_id; + return false; + } res.payments.clear(); std::list<wallet2::payment_details> payment_list; |