aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/blockchain_db/lmdb/db_lmdb.cpp45
-rw-r--r--src/rpc/core_rpc_server.cpp2
-rw-r--r--tests/unit_tests/checkpoints.cpp6
-rw-r--r--tests/unit_tests/epee_levin_protocol_handler_async.cpp2
4 files changed, 36 insertions, 19 deletions
diff --git a/src/blockchain_db/lmdb/db_lmdb.cpp b/src/blockchain_db/lmdb/db_lmdb.cpp
index 9824d7376..2cd3943e9 100644
--- a/src/blockchain_db/lmdb/db_lmdb.cpp
+++ b/src/blockchain_db/lmdb/db_lmdb.cpp
@@ -1098,7 +1098,9 @@ void BlockchainLMDB::open(const std::string& filename, const int mdb_flags)
mdb_set_compare(txn, m_properties, compare_string);
- mdb_drop(txn, m_hf_starting_heights, 1);
+ result = mdb_drop(txn, m_hf_starting_heights, 1);
+ if (result)
+ throw0(DB_ERROR(lmdb_error("Failed to drop m_hf_starting_heights: ", result).c_str()));
// get and keep current height
MDB_stat db_stats;
@@ -1224,17 +1226,28 @@ void BlockchainLMDB::reset()
mdb_txn_safe txn;
if (auto result = mdb_txn_begin(m_env, NULL, 0, txn))
throw0(DB_ERROR(lmdb_error("Failed to create a transaction for the db: ", result).c_str()));
- mdb_drop(txn, m_blocks, 0);
- mdb_drop(txn, m_block_info, 0);
- mdb_drop(txn, m_block_heights, 0);
- mdb_drop(txn, m_txs, 0);
- mdb_drop(txn, m_tx_outputs, 0);
- mdb_drop(txn, m_output_txs, 0);
- mdb_drop(txn, m_output_amounts, 0);
- mdb_drop(txn, m_spent_keys, 0);
- mdb_drop(txn, m_hf_starting_heights, 0);
- mdb_drop(txn, m_hf_versions, 0);
- mdb_drop(txn, m_properties, 0);
+ if (auto result = mdb_drop(txn, m_blocks, 0))
+ throw0(DB_ERROR(lmdb_error("Failed to drop m_blocks: ", result).c_str()));
+ if (auto result = mdb_drop(txn, m_block_info, 0))
+ throw0(DB_ERROR(lmdb_error("Failed to drop m_block_info: ", result).c_str()));
+ if (auto result = mdb_drop(txn, m_block_heights, 0))
+ throw0(DB_ERROR(lmdb_error("Failed to drop m_block_heights: ", result).c_str()));
+ if (auto result = mdb_drop(txn, m_txs, 0))
+ throw0(DB_ERROR(lmdb_error("Failed to drop m_txs: ", result).c_str()));
+ if (auto result = mdb_drop(txn, m_tx_outputs, 0))
+ throw0(DB_ERROR(lmdb_error("Failed to drop m_tx_outputs: ", result).c_str()));
+ if (auto result = mdb_drop(txn, m_output_txs, 0))
+ throw0(DB_ERROR(lmdb_error("Failed to drop m_output_txs: ", result).c_str()));
+ if (auto result = mdb_drop(txn, m_output_amounts, 0))
+ throw0(DB_ERROR(lmdb_error("Failed to drop m_output_amounts: ", result).c_str()));
+ if (auto result = mdb_drop(txn, m_spent_keys, 0))
+ throw0(DB_ERROR(lmdb_error("Failed to drop m_spent_keys: ", result).c_str()));
+ if (auto result = mdb_drop(txn, m_hf_starting_heights, 0))
+ throw0(DB_ERROR(lmdb_error("Failed to drop m_hf_starting_heights: ", result).c_str()));
+ if (auto result = mdb_drop(txn, m_hf_versions, 0))
+ throw0(DB_ERROR(lmdb_error("Failed to drop m_hf_versions: ", result).c_str()));
+ if (auto result = mdb_drop(txn, m_properties, 0))
+ throw0(DB_ERROR(lmdb_error("Failed to drop m_properties: ", result).c_str()));
txn.commit();
m_height = 0;
m_num_outputs = 0;
@@ -3191,8 +3204,12 @@ void BlockchainLMDB::migrate_0_1()
result = mdb_cursor_get(c_blocks, &k, &v, MDB_NEXT);
if (result == MDB_NOTFOUND) {
MDB_val_set(pk, "txblk");
- mdb_cursor_get(c_props, &pk, &v, MDB_SET);
- mdb_cursor_del(c_props, 0);
+ result = mdb_cursor_get(c_props, &pk, &v, MDB_SET);
+ if (result)
+ throw0(DB_ERROR(lmdb_error("Failed to get a record from props: ", result).c_str()));
+ result = mdb_cursor_del(c_props, 0);
+ if (result)
+ throw0(DB_ERROR(lmdb_error("Failed to delete a record from props: ", result).c_str()));
batch_stop();
break;
} else if (result)
diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp
index 35200c5f9..166d1ba94 100644
--- a/src/rpc/core_rpc_server.cpp
+++ b/src/rpc/core_rpc_server.cpp
@@ -525,7 +525,7 @@ namespace cryptonote
{
std::list<nodetool::peerlist_entry> white_list;
std::list<nodetool::peerlist_entry> gray_list;
- m_p2p.get_peerlist_manager().get_peerlist_full(white_list, gray_list);
+ m_p2p.get_peerlist_manager().get_peerlist_full(gray_list, white_list);
for (auto & entry : white_list)
diff --git a/tests/unit_tests/checkpoints.cpp b/tests/unit_tests/checkpoints.cpp
index cb490023d..b1d251d26 100644
--- a/tests/unit_tests/checkpoints.cpp
+++ b/tests/unit_tests/checkpoints.cpp
@@ -49,7 +49,7 @@ TEST(checkpoints_is_alternative_block_allowed, handles_empty_checkpoints)
TEST(checkpoints_is_alternative_block_allowed, handles_one_checkpoint)
{
checkpoints cp;
- cp.add_checkpoint(5, "0000000000000000000000000000000000000000000000000000000000000000");
+ ASSERT_TRUE(cp.add_checkpoint(5, "0000000000000000000000000000000000000000000000000000000000000000"));
ASSERT_FALSE(cp.is_alternative_block_allowed(0, 0));
@@ -87,8 +87,8 @@ TEST(checkpoints_is_alternative_block_allowed, handles_one_checkpoint)
TEST(checkpoints_is_alternative_block_allowed, handles_two_and_more_checkpoints)
{
checkpoints cp;
- cp.add_checkpoint(5, "0000000000000000000000000000000000000000000000000000000000000000");
- cp.add_checkpoint(9, "0000000000000000000000000000000000000000000000000000000000000000");
+ ASSERT_TRUE(cp.add_checkpoint(5, "0000000000000000000000000000000000000000000000000000000000000000"));
+ ASSERT_TRUE(cp.add_checkpoint(9, "0000000000000000000000000000000000000000000000000000000000000000"));
ASSERT_FALSE(cp.is_alternative_block_allowed(0, 0));
diff --git a/tests/unit_tests/epee_levin_protocol_handler_async.cpp b/tests/unit_tests/epee_levin_protocol_handler_async.cpp
index dd0ca1549..ca110eb59 100644
--- a/tests/unit_tests/epee_levin_protocol_handler_async.cpp
+++ b/tests/unit_tests/epee_levin_protocol_handler_async.cpp
@@ -375,7 +375,7 @@ TEST_F(positive_test_connection_to_levin_protocol_handler_calls, handler_process
ASSERT_EQ(expected_out_data.size(), resp_head.m_cb);
ASSERT_FALSE(resp_head.m_have_to_return_data);
ASSERT_EQ(LEVIN_PROTOCOL_VER_1, resp_head.m_protocol_version);
- ASSERT_TRUE(0 != (resp_head.m_flags | LEVIN_PACKET_RESPONSE));
+ ASSERT_TRUE(0 != (resp_head.m_flags & LEVIN_PACKET_RESPONSE));
}
TEST_F(positive_test_connection_to_levin_protocol_handler_calls, handler_processes_handle_read_as_notify)