Skip to content

Commit

Permalink
Merge pull request monero-project#18 from moneromooo-monero/blockchain
Browse files Browse the repository at this point in the history
Blockchain
  • Loading branch information
tewinget authored and warptangent committed Jan 5, 2015
2 parents c50cd95 + ad8200a commit 4fa1a83
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
7 changes: 6 additions & 1 deletion src/blockchain_converter/blockchain_converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
16 changes: 5 additions & 11 deletions src/cryptonote_core/BlockchainDB_impl/db_lmdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -1310,9 +1304,9 @@ std::vector<uint64_t> 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();
Expand Down

0 comments on commit 4fa1a83

Please sign in to comment.