From 1362846dd7c7e50b8804e24ece1a750472cc4485 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Fri, 19 Dec 2014 18:18:21 +0000 Subject: [PATCH 1/3] blockchain_converter: add --testnet for converting testnet blockchain --- src/blockchain_converter/blockchain_converter.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/blockchain_converter/blockchain_converter.cpp b/src/blockchain_converter/blockchain_converter.cpp index f2dd10b1..57822700 100644 --- a/src/blockchain_converter/blockchain_converter.cpp +++ b/src/blockchain_converter/blockchain_converter.cpp @@ -59,7 +59,12 @@ struct fake_core int main(int argc, char* argv[]) { - boost::filesystem::path default_data_path {tools::get_default_data_dir()}; + std::string dir = tools::get_default_data_dir(); + boost::filesystem::path default_data_path {dir}; + if (argc >= 2 && !strcmp(argv[1], "--testnet")) { + default_data_path /= "testnet"; + } + fake_core c(default_data_path); BlockchainDB *blockchain; From 57b80c541e01df8ad83aa6f8611c2ebc5669c716 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Sat, 20 Dec 2014 18:35:54 +0000 Subject: [PATCH 2/3] db_lmdb: remove redundant checks --- src/cryptonote_core/BlockchainDB_impl/db_lmdb.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/cryptonote_core/BlockchainDB_impl/db_lmdb.cpp b/src/cryptonote_core/BlockchainDB_impl/db_lmdb.cpp index e96b9f90..ee5c0fa9 100644 --- a/src/cryptonote_core/BlockchainDB_impl/db_lmdb.cpp +++ b/src/cryptonote_core/BlockchainDB_impl/db_lmdb.cpp @@ -1162,12 +1162,9 @@ tx_out BlockchainLMDB::get_output(const crypto::hash& h, const uint64_t& index) mdb_cursor_get(cur, &k, &v, MDB_FIRST_DUP); - if (index != 0) + for (uint64_t i = 0; i < index; ++i) { - for (uint64_t i = 0; i < index; ++i) - { - mdb_cursor_get(cur, &k, &v, MDB_NEXT_DUP); - } + mdb_cursor_get(cur, &k, &v, MDB_NEXT_DUP); } mdb_cursor_get(cur, &k, &v, MDB_GET_CURRENT); @@ -1264,12 +1261,9 @@ tx_out_index BlockchainLMDB::get_output_tx_and_index(const uint64_t& amount, con mdb_cursor_get(cur, &k, &v, MDB_FIRST_DUP); - if (index != 0) + for (uint64_t i = 0; i < index; ++i) { - for (uint64_t i = 0; i < index; ++i) - { - mdb_cursor_get(cur, &k, &v, MDB_NEXT_DUP); - } + mdb_cursor_get(cur, &k, &v, MDB_NEXT_DUP); } mdb_cursor_get(cur, &k, &v, MDB_GET_CURRENT); From ad8200a5731e462cf191e49570359283d760b372 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Sat, 20 Dec 2014 18:36:22 +0000 Subject: [PATCH 3/3] db_lmdb: fix global index calculation off by 1 This finally fixes raw tx being accepted by the daemon. --- src/cryptonote_core/BlockchainDB_impl/db_lmdb.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cryptonote_core/BlockchainDB_impl/db_lmdb.cpp b/src/cryptonote_core/BlockchainDB_impl/db_lmdb.cpp index ee5c0fa9..5b71dcf0 100644 --- a/src/cryptonote_core/BlockchainDB_impl/db_lmdb.cpp +++ b/src/cryptonote_core/BlockchainDB_impl/db_lmdb.cpp @@ -1304,9 +1304,9 @@ std::vector BlockchainLMDB::get_tx_output_indices(const crypto::hash& for (uint64_t i = 0; i < num_elems; ++i) { - mdb_cursor_get(cur, &k, &v, MDB_NEXT_DUP); mdb_cursor_get(cur, &k, &v, MDB_GET_CURRENT); index_vec.push_back(*(const uint64_t *)v.mv_data); + mdb_cursor_get(cur, &k, &v, MDB_NEXT_DUP); } cur.close();