mirror of
https://git.wownero.com/wownero/wownero.git
synced 2024-08-15 01:03:23 +00:00
add a few checks where it seems appropriate
This commit is contained in:
parent
581994b61c
commit
25a7cfdb4a
7 changed files with 8 additions and 2 deletions
|
@ -707,7 +707,7 @@ uint64_t BlockchainLMDB::get_estimated_batch_size(uint64_t batch_num_blocks, uin
|
||||||
++num_blocks_used;
|
++num_blocks_used;
|
||||||
}
|
}
|
||||||
if (my_rtxn) block_rtxn_stop();
|
if (my_rtxn) block_rtxn_stop();
|
||||||
avg_block_size = total_block_size / num_blocks_used;
|
avg_block_size = total_block_size / (num_blocks_used ? num_blocks_used : 1);
|
||||||
MDEBUG("average block size across recent " << num_blocks_used << " blocks: " << avg_block_size);
|
MDEBUG("average block size across recent " << num_blocks_used << " blocks: " << avg_block_size);
|
||||||
}
|
}
|
||||||
estim:
|
estim:
|
||||||
|
|
|
@ -637,6 +637,7 @@ static void inc_per_amount_outputs(MDB_txn *txn, uint64_t amount, uint64_t total
|
||||||
v.mv_size = 2 * sizeof(uint64_t);
|
v.mv_size = 2 * sizeof(uint64_t);
|
||||||
v.mv_data = (void*)data;
|
v.mv_data = (void*)data;
|
||||||
dbr = mdb_cursor_put(cur, &k, &v, 0);
|
dbr = mdb_cursor_put(cur, &k, &v, 0);
|
||||||
|
CHECK_AND_ASSERT_THROW_MES(!dbr, "Failed to write record for per amount outputs: " + std::string(mdb_strerror(dbr)));
|
||||||
mdb_cursor_close(cur);
|
mdb_cursor_close(cur);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -447,6 +447,7 @@ namespace cryptonote
|
||||||
m_nettype = FAKECHAIN;
|
m_nettype = FAKECHAIN;
|
||||||
}
|
}
|
||||||
bool r = handle_command_line(vm);
|
bool r = handle_command_line(vm);
|
||||||
|
CHECK_AND_ASSERT_MES(r, false, "Failed to handle command line");
|
||||||
|
|
||||||
std::string db_type = command_line::get_arg(vm, cryptonote::arg_db_type);
|
std::string db_type = command_line::get_arg(vm, cryptonote::arg_db_type);
|
||||||
std::string db_sync_mode = command_line::get_arg(vm, cryptonote::arg_db_sync_mode);
|
std::string db_sync_mode = command_line::get_arg(vm, cryptonote::arg_db_sync_mode);
|
||||||
|
@ -634,6 +635,7 @@ namespace cryptonote
|
||||||
};
|
};
|
||||||
const difficulty_type fixed_difficulty = command_line::get_arg(vm, arg_fixed_difficulty);
|
const difficulty_type fixed_difficulty = command_line::get_arg(vm, arg_fixed_difficulty);
|
||||||
r = m_blockchain_storage.init(db.release(), m_nettype, m_offline, regtest ? ®test_test_options : test_options, fixed_difficulty, get_checkpoints);
|
r = m_blockchain_storage.init(db.release(), m_nettype, m_offline, regtest ? ®test_test_options : test_options, fixed_difficulty, get_checkpoints);
|
||||||
|
CHECK_AND_ASSERT_MES(r, false, "Failed to initialize blockchain storage");
|
||||||
|
|
||||||
r = m_mempool.init(max_txpool_weight);
|
r = m_mempool.init(max_txpool_weight);
|
||||||
CHECK_AND_ASSERT_MES(r, false, "Failed to initialize memory pool");
|
CHECK_AND_ASSERT_MES(r, false, "Failed to initialize memory pool");
|
||||||
|
|
|
@ -1510,7 +1510,7 @@ namespace cryptonote
|
||||||
ok = ok && getheight_res.status == CORE_RPC_STATUS_OK;
|
ok = ok && getheight_res.status == CORE_RPC_STATUS_OK;
|
||||||
|
|
||||||
m_should_use_bootstrap_daemon = ok && top_height + 10 < getheight_res.height;
|
m_should_use_bootstrap_daemon = ok && top_height + 10 < getheight_res.height;
|
||||||
MINFO((m_should_use_bootstrap_daemon ? "Using" : "Not using") << " the bootstrap daemon (our height: " << top_height << ", bootstrap daemon's height: " << getheight_res.height << ")");
|
MINFO((m_should_use_bootstrap_daemon ? "Using" : "Not using") << " the bootstrap daemon (our height: " << top_height << ", bootstrap daemon's height: " << (ok ? getheight_res.height : 0) << ")");
|
||||||
}
|
}
|
||||||
if (!m_should_use_bootstrap_daemon)
|
if (!m_should_use_bootstrap_daemon)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -546,6 +546,7 @@ void block_tracker::global_indices(const cryptonote::transaction *tx, std::vecto
|
||||||
void block_tracker::get_fake_outs(size_t num_outs, uint64_t amount, uint64_t global_index, uint64_t cur_height, std::vector<get_outs_entry> &outs){
|
void block_tracker::get_fake_outs(size_t num_outs, uint64_t amount, uint64_t global_index, uint64_t cur_height, std::vector<get_outs_entry> &outs){
|
||||||
auto & vct = m_outs[amount];
|
auto & vct = m_outs[amount];
|
||||||
const size_t n_outs = vct.size();
|
const size_t n_outs = vct.size();
|
||||||
|
CHECK_AND_ASSERT_THROW_MES(n_outs > 0, "n_outs is 0");
|
||||||
|
|
||||||
std::set<size_t> used;
|
std::set<size_t> used;
|
||||||
std::vector<size_t> choices;
|
std::vector<size_t> choices;
|
||||||
|
|
|
@ -163,6 +163,7 @@ bool wallet_tools::fill_tx_sources(tools::wallet2 * wallet, std::vector<cryptono
|
||||||
|
|
||||||
void wallet_tools::gen_tx_src(size_t mixin, uint64_t cur_height, const tools::wallet2::transfer_details & td, cryptonote::tx_source_entry & src, block_tracker &bt)
|
void wallet_tools::gen_tx_src(size_t mixin, uint64_t cur_height, const tools::wallet2::transfer_details & td, cryptonote::tx_source_entry & src, block_tracker &bt)
|
||||||
{
|
{
|
||||||
|
CHECK_AND_ASSERT_THROW_MES(mixin != 0, "mixin is zero");
|
||||||
src.amount = td.amount();
|
src.amount = td.amount();
|
||||||
src.rct = td.is_rct();
|
src.rct = td.is_rct();
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,7 @@ TEST(protocol_pack, protocol_pack_command)
|
||||||
|
|
||||||
cryptonote::NOTIFY_RESPONSE_CHAIN_ENTRY::request r2;
|
cryptonote::NOTIFY_RESPONSE_CHAIN_ENTRY::request r2;
|
||||||
res = epee::serialization::load_t_from_binary(r2, buff);
|
res = epee::serialization::load_t_from_binary(r2, buff);
|
||||||
|
ASSERT_TRUE(res);
|
||||||
ASSERT_TRUE(r.m_block_ids.size() == i);
|
ASSERT_TRUE(r.m_block_ids.size() == i);
|
||||||
ASSERT_TRUE(r.start_height == 1);
|
ASSERT_TRUE(r.start_height == 1);
|
||||||
ASSERT_TRUE(r.total_height == 3);
|
ASSERT_TRUE(r.total_height == 3);
|
||||||
|
|
Loading…
Reference in a new issue