Output stacktrace with custom debug assert (#2568)

* Output stacktrace with debug assert

* Error on CI if assert is used

* Remove <cassert> and add debug_assert to platform specific dirs

* Fix CI regular expression

* Missed updating assert for newly added files
This commit is contained in:
Wesley Shillingford 2020-02-24 15:59:05 +00:00 committed by GitHub
commit fb53a08f3a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
89 changed files with 579 additions and 574 deletions

View file

@ -10,16 +10,22 @@ OS=`uname`
# This is to prevent out of scope access in async_write from asio which is not picked up by static analysers
if [[ $(grep -rl --exclude="*asio.hpp" "asio::async_write" ./nano) ]]; then
echo "using boost::asio::async_write directly is not permitted (except in nano/lib/asio.hpp). Use nano::async_write instead"
echo "Using boost::asio::async_write directly is not permitted (except in nano/lib/asio.hpp). Use nano::async_write instead"
exit 1
fi
# prevent unsolicited use of std::lock_guard & std::unique_lock outside of allowed areas
if [[ $(grep -rl --exclude={"*random_pool.cpp","*random_pool.hpp","*random_pool_shuffle.hpp","*locks.hpp","*locks.cpp"} "std::unique_lock\|std::lock_guard\|std::condition_variable" ./nano) ]]; then
echo "using std::unique_lock, std::lock_guard or std::condition_variable is not permitted (except in nano/lib/locks.hpp and non-nano dependent libraries). Use the nano::* versions instead"
echo "Using std::unique_lock, std::lock_guard or std::condition_variable is not permitted (except in nano/lib/locks.hpp and non-nano dependent libraries). Use the nano::* versions instead"
exit 1
fi
if [[ $(grep -rlP "^\s*assert \(" ./nano) ]]; then
echo "Using assert is not permitted. Use debug_assert instead."
exit 1
fi
# prevent unsolicited use of std::lock_guard & std::unique_lock outside of allowed areas
mkdir build
pushd build

View file

@ -727,7 +727,7 @@ TEST (block_store, large_iteration)
for (auto i (store->latest_begin (transaction, 0)), n (store->latest_end ()); i != n; ++i)
{
nano::account current (i->first);
assert (current.number () > previous.number ());
ASSERT_GT (current.number (), previous.number ());
accounts2.insert (current);
previous = current;
}
@ -873,8 +873,7 @@ TEST (mdb_block_store, upgrade_v2_v3)
auto rep_block = ledger.representative (transaction, ledger.latest (transaction, nano::test_genesis_key.pub));
nano::account_info_v5 info_old (info.head, rep_block, info.open_block, info.balance, info.modified);
auto status (mdb_put (store.env.tx (transaction), store.accounts_v0, nano::mdb_val (nano::test_genesis_key.pub), nano::mdb_val (sizeof (info_old), &info_old), 0));
(void)status;
assert (status == 0);
ASSERT_EQ (status, 0);
store.confirmation_height_del (transaction, nano::genesis_account);
}
nano::logger_mt logger;
@ -2320,7 +2319,7 @@ void write_sideband_v15 (nano::mdb_store & store_a, nano::transaction & transact
auto block = store_a.block_get (transaction_a, block_a.hash (), &sideband);
ASSERT_NE (block, nullptr);
assert (sideband.details.epoch <= nano::epoch::max);
ASSERT_LE (sideband.details.epoch, nano::epoch::max);
// Simulated by writing 0 on every of the most significant bits, leaving out epoch only, as if pre-upgrade
nano::block_sideband sideband_v15 (sideband.type, sideband.account, sideband.successor, sideband.balance, sideband.timestamp, sideband.height, sideband.details.epoch, false, false, false);
std::vector<uint8_t> data;
@ -2341,8 +2340,7 @@ void modify_account_info_to_v13 (nano::mdb_store & store, nano::transaction cons
ASSERT_FALSE (store.account_get (transaction, account, info));
nano::account_info_v13 account_info_v13 (info.head, rep_block, info.open_block, info.balance, info.modified, info.block_count, info.epoch ());
auto status (mdb_put (store.env.tx (transaction), (info.epoch () == nano::epoch::epoch_0) ? store.accounts_v0 : store.accounts_v1, nano::mdb_val (account), nano::mdb_val (account_info_v13), 0));
(void)status;
assert (status == 0);
ASSERT_EQ (status, 0);
}
void modify_account_info_to_v14 (nano::mdb_store & store, nano::transaction const & transaction, nano::account const & account, uint64_t confirmation_height, nano::block_hash const & rep_block)
@ -2351,15 +2349,13 @@ void modify_account_info_to_v14 (nano::mdb_store & store, nano::transaction cons
ASSERT_FALSE (store.account_get (transaction, account, info));
nano::account_info_v14 account_info_v14 (info.head, rep_block, info.open_block, info.balance, info.modified, info.block_count, confirmation_height, info.epoch ());
auto status (mdb_put (store.env.tx (transaction), info.epoch () == nano::epoch::epoch_0 ? store.accounts_v0 : store.accounts_v1, nano::mdb_val (account), nano::mdb_val (account_info_v14), 0));
(void)status;
assert (status == 0);
ASSERT_EQ (status, 0);
}
void modify_confirmation_height_to_v15 (nano::mdb_store & store, nano::transaction const & transaction, nano::account const & account, uint64_t confirmation_height)
{
auto status (mdb_put (store.env.tx (transaction), store.confirmation_height, nano::mdb_val (account), nano::mdb_val (confirmation_height), 0));
(void)status;
assert (status == 0);
ASSERT_EQ (status, 0);
}
void modify_genesis_account_info_to_v5 (nano::mdb_store & store, nano::transaction const & transaction)
@ -2370,7 +2366,6 @@ void modify_genesis_account_info_to_v5 (nano::mdb_store & store, nano::transacti
visitor.compute (info.head);
nano::account_info_v5 info_old (info.head, visitor.result, info.open_block, info.balance, info.modified);
auto status (mdb_put (store.env.tx (transaction), store.accounts_v0, nano::mdb_val (nano::test_genesis_key.pub), nano::mdb_val (sizeof (info_old), &info_old), 0));
(void)status;
assert (status == 0);
ASSERT_EQ (status, 0);
}
}

View file

@ -17,14 +17,14 @@ void add_callback_stats (nano::node & node, std::vector<nano::block_hash> * obse
if (mutex)
{
nano::lock_guard<std::mutex> guard (*mutex);
assert (observer_order);
debug_assert (observer_order);
observer_order->push_back (status_a.winner->hash ());
}
});
}
nano::stat::detail get_stats_detail (nano::confirmation_height_mode mode_a)
{
assert (mode_a == nano::confirmation_height_mode::bounded || mode_a == nano::confirmation_height_mode::unbounded);
debug_assert (mode_a == nano::confirmation_height_mode::bounded || mode_a == nano::confirmation_height_mode::unbounded);
return (mode_a == nano::confirmation_height_mode::bounded) ? nano::stat::detail::blocks_confirmed_bounded : nano::stat::detail::blocks_confirmed_unbounded;
}
}

View file

@ -45,14 +45,14 @@ public:
void await_ack ()
{
assert (socket->is_open ());
debug_assert (socket->is_open ());
boost::beast::flat_buffer buffer;
socket->read (buffer);
}
boost::optional<std::string> get_response (std::chrono::seconds const deadline = 5s)
{
assert (deadline > 0s);
debug_assert (deadline > 0s);
boost::optional<std::string> result;
auto buffer (std::make_shared<boost::beast::flat_buffer> ());
socket->async_read (*buffer, [&result, &buffer, socket = this->socket](boost::beast::error_code const & ec, std::size_t const /*n*/) {

View file

@ -50,7 +50,7 @@ size_t get_allocated_size ()
std::vector<size_t> allocated;
record_allocations_new_delete_allocator<T> alloc (&allocated);
(void)std::allocate_shared<T, record_allocations_new_delete_allocator<T>> (alloc);
assert (allocated.size () == 1);
debug_assert (allocated.size () == 1);
return allocated.front ();
}
}

View file

@ -73,7 +73,7 @@ TEST (signature_checker, many_multi_threaded)
for (int i = 0; i < num_check_sizes; ++i)
{
auto check_size = check_sizes[i];
assert (check_size > 0);
ASSERT_GT (check_size, 0);
auto last_signature_index = check_size - 1;
messages[i].resize (check_size);

View file

@ -110,8 +110,7 @@ TEST (wallets, upgrade)
auto rep_block = node1->rep_block (nano::genesis_account);
nano::account_info_v13 account_info_v13 (info.head, rep_block, info.open_block, info.balance, info.modified, info.block_count, info.epoch ());
auto status (mdb_put (mdb_store.env.tx (transaction_destination), info.epoch () == nano::epoch::epoch_0 ? mdb_store.accounts_v0 : mdb_store.accounts_v1, nano::mdb_val (nano::test_genesis_key.pub), nano::mdb_val (account_info_v13), 0));
(void)status;
assert (status == 0);
ASSERT_EQ (status, 0);
mdb_store.confirmation_height_del (transaction_destination, nano::genesis_account);
}
auto node1 (std::make_shared<nano::node> (system.io_ctx, path, system.alarm, node_config1, system.work));

View file

@ -85,6 +85,7 @@ target_compile_definitions(nano_lib
-DMINOR_VERSION_STRING=${CPACK_PACKAGE_VERSION_MINOR}
-DPATCH_VERSION_STRING=${CPACK_PACKAGE_VERSION_PATCH}
-DPRE_RELEASE_VERSION_STRING=${CPACK_PACKAGE_VERSION_PRE_RELEASE}
-DCI=${CI_TEST}
PUBLIC
-DACTIVE_NETWORK=${ACTIVE_NETWORK}
)

View file

@ -186,7 +186,7 @@ std::error_code check_fields_set (uint8_t block_all_flags, uint8_t build_state)
{
// Convert the first bit set to a field mask and look up the error code.
auto build_flags_mask = static_cast<uint8_t> (ffs_mask (res));
assert (ec_map.find (build_flags_mask) != ec_map.end ());
debug_assert (ec_map.find (build_flags_mask) != ec_map.end ());
ec = ec_map[build_flags_mask];
}
return ec;
@ -658,7 +658,7 @@ std::unique_ptr<BLOCKTYPE> nano::abstract_builder<BLOCKTYPE, BUILDER>::build ()
{
static_cast<BUILDER *> (this)->validate ();
}
assert (!ec);
debug_assert (!ec);
return std::move (block);
}

View file

@ -55,7 +55,7 @@ size_t nano::block::size (nano::block_type type_a)
{
case nano::block_type::invalid:
case nano::block_type::not_a_block:
assert (false);
debug_assert (false);
break;
case nano::block_type::send:
result = nano::send_block::size;
@ -81,10 +81,10 @@ nano::block_hash nano::block::generate_hash () const
nano::block_hash result;
blake2b_state hash_l;
auto status (blake2b_init (&hash_l, sizeof (result.bytes)));
assert (status == 0);
debug_assert (status == 0);
hash (hash_l);
status = blake2b_final (&hash_l, result.bytes.data (), sizeof (result.bytes));
assert (status == 0);
debug_assert (status == 0);
return result;
}
@ -102,7 +102,7 @@ nano::block_hash const & nano::block::hash () const
{
// Once a block is created, it should not be modified (unless using refresh ())
// This would invalidate the cache; check it hasn't changed.
assert (cached_hash == generate_hash ());
debug_assert (cached_hash == generate_hash ());
}
else
{
@ -228,11 +228,11 @@ nano::send_hashables::send_hashables (bool & error_a, boost::property_tree::ptre
void nano::send_hashables::hash (blake2b_state & hash_a) const
{
auto status (blake2b_update (&hash_a, previous.bytes.data (), sizeof (previous.bytes)));
assert (status == 0);
debug_assert (status == 0);
status = blake2b_update (&hash_a, destination.bytes.data (), sizeof (destination.bytes));
assert (status == 0);
debug_assert (status == 0);
status = blake2b_update (&hash_a, balance.bytes.data (), sizeof (balance.bytes));
assert (status == 0);
debug_assert (status == 0);
}
void nano::send_block::serialize (nano::stream & stream_a) const
@ -293,7 +293,7 @@ bool nano::send_block::deserialize_json (boost::property_tree::ptree const & tre
auto error (false);
try
{
assert (tree_a.get<std::string> ("type") == "send");
debug_assert (tree_a.get<std::string> ("type") == "send");
auto previous_l (tree_a.get<std::string> ("previous"));
auto destination_l (tree_a.get<std::string> ("destination"));
auto balance_l (tree_a.get<std::string> ("balance"));
@ -485,7 +485,7 @@ hashables (source_a, representative_a, account_a),
signature (nano::sign_message (prv_a, pub_a, hash ())),
work (work_a)
{
assert (!representative_a.is_zero ());
debug_assert (!representative_a.is_zero ());
}
nano::open_block::open_block (nano::block_hash const & source_a, nano::account const & representative_a, nano::account const & account_a, std::nullptr_t) :
@ -614,7 +614,7 @@ bool nano::open_block::deserialize_json (boost::property_tree::ptree const & tre
auto error (false);
try
{
assert (tree_a.get<std::string> ("type") == "open");
debug_assert (tree_a.get<std::string> ("type") == "open");
auto source_l (tree_a.get<std::string> ("source"));
auto representative_l (tree_a.get<std::string> ("representative"));
auto account_l (tree_a.get<std::string> ("account"));
@ -855,7 +855,7 @@ bool nano::change_block::deserialize_json (boost::property_tree::ptree const & t
auto error (false);
try
{
assert (tree_a.get<std::string> ("type") == "change");
debug_assert (tree_a.get<std::string> ("type") == "change");
auto previous_l (tree_a.get<std::string> ("previous"));
auto representative_l (tree_a.get<std::string> ("representative"));
auto work_l (tree_a.get<std::string> ("work"));
@ -1147,7 +1147,7 @@ bool nano::state_block::deserialize_json (boost::property_tree::ptree const & tr
auto error (false);
try
{
assert (tree_a.get<std::string> ("type") == "state");
debug_assert (tree_a.get<std::string> ("type") == "state");
auto account_l (tree_a.get<std::string> ("account"));
auto previous_l (tree_a.get<std::string> ("previous"));
auto representative_l (tree_a.get<std::string> ("representative"));
@ -1338,7 +1338,7 @@ std::shared_ptr<nano::block> nano::deserialize_block (nano::stream & stream_a, n
}
default:
#ifndef NANO_FUZZER_TEST
assert (false);
debug_assert (false);
#endif
break;
}
@ -1415,7 +1415,7 @@ bool nano::receive_block::deserialize_json (boost::property_tree::ptree const &
auto error (false);
try
{
assert (tree_a.get<std::string> ("type") == "receive");
debug_assert (tree_a.get<std::string> ("type") == "receive");
auto previous_l (tree_a.get<std::string> ("previous"));
auto source_l (tree_a.get<std::string> ("source"));
auto work_l (tree_a.get<std::string> ("work"));

View file

@ -1,9 +1,8 @@
#include "nano/lib/errors.hpp"
#include <nano/lib/errors.hpp>
#include <nano/lib/utility.hpp>
#include <boost/system/error_code.hpp>
#include <cassert>
std::string nano::error_common_messages::message (int ev) const
{
switch (static_cast<nano::error_common> (ev))
@ -291,7 +290,7 @@ std::error_code nano::error_conversion::convert (const boost::system::error_code
return std::error_code (error.value (),
nano::error_conversion::generic_category ());
}
assert (false);
debug_assert (false);
return nano::error_common::invalid_type_conversion;
}

View file

@ -1,4 +1,5 @@
#include <nano/lib/ipc.hpp>
#include <nano/lib/utility.hpp>
nano::ipc::socket_base::socket_base (boost::asio::io_context & io_ctx_a) :
io_timer (io_ctx_a)
@ -28,7 +29,7 @@ void nano::ipc::socket_base::timer_cancel ()
{
boost::system::error_code ec;
io_timer.cancel (ec);
assert (!ec);
debug_assert (!ec);
}
nano::ipc::dsock_file_remover::dsock_file_remover (std::string const & file_a) :

View file

@ -1,6 +1,7 @@
#pragma once
#include <nano/lib/locks.hpp>
#include <nano/lib/utility.hpp>
#include <boost/log/sources/severity_logger.hpp>
#include <boost/log/trivial.hpp>
@ -31,7 +32,7 @@ inline boost::log::formatting_ostream & operator<< (boost::log::formatting_ostre
};
nano::severity_level level = manip.get ();
assert (static_cast<int> (level) < strings.size ());
debug_assert (static_cast<int> (level) < strings.size ());
strm << strings[static_cast<int> (level)];
return strm;
}

View file

@ -14,14 +14,14 @@ char const * account_lookup ("13456789abcdefghijkmnopqrstuwxyz");
char const * account_reverse ("~0~1234567~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~89:;<=>?@AB~CDEFGHIJK~LMNO~~~~~");
char account_encode (uint8_t value)
{
assert (value < 32);
debug_assert (value < 32);
auto result (account_lookup[value]);
return result;
}
uint8_t account_decode (char value)
{
assert (value >= '0');
assert (value <= '~');
debug_assert (value >= '0');
debug_assert (value <= '~');
auto result (account_reverse[value - 0x30]);
if (result != '~')
{
@ -33,7 +33,7 @@ uint8_t account_decode (char value)
void nano::public_key::encode_account (std::string & destination_a) const
{
assert (destination_a.empty ());
debug_assert (destination_a.empty ());
destination_a.reserve (65);
uint64_t check (0);
blake2b_state hash;
@ -200,7 +200,7 @@ nano::uint256_t nano::uint256_union::number () const
void nano::uint256_union::encode_hex (std::string & text) const
{
assert (text.empty ());
debug_assert (text.empty ());
std::stringstream stream;
stream << std::hex << std::uppercase << std::noshowbase << std::setw (64) << std::setfill ('0');
stream << number ();
@ -238,7 +238,7 @@ bool nano::uint256_union::decode_hex (std::string const & text)
void nano::uint256_union::encode_dec (std::string & text) const
{
assert (text.empty ());
debug_assert (text.empty ());
std::stringstream stream;
stream << std::dec << std::noshowbase;
stream << number ();
@ -317,7 +317,7 @@ nano::uint512_t nano::uint512_union::number () const
void nano::uint512_union::encode_hex (std::string & text) const
{
assert (text.empty ());
debug_assert (text.empty ());
std::stringstream stream;
stream << std::hex << std::uppercase << std::noshowbase << std::setw (128) << std::setfill ('0');
stream << number ();
@ -481,7 +481,7 @@ nano::uint128_t nano::uint128_union::number () const
void nano::uint128_union::encode_hex (std::string & text) const
{
assert (text.empty ());
debug_assert (text.empty ());
std::stringstream stream;
stream << std::hex << std::uppercase << std::noshowbase << std::setw (32) << std::setfill ('0');
stream << number ();
@ -515,7 +515,7 @@ bool nano::uint128_union::decode_hex (std::string const & text)
void nano::uint128_union::encode_dec (std::string & text) const
{
assert (text.empty ());
debug_assert (text.empty ());
std::stringstream stream;
stream << std::dec << std::noshowbase;
stream << number ();
@ -894,7 +894,7 @@ std::string nano::to_string (double const value_a, int const precision_a)
uint64_t nano::difficulty::from_multiplier (double const multiplier_a, uint64_t const base_difficulty_a)
{
assert (multiplier_a > 0.);
debug_assert (multiplier_a > 0.);
nano::uint128_t reverse_difficulty ((-base_difficulty_a) / multiplier_a);
if (reverse_difficulty > std::numeric_limits<std::uint64_t>::max ())
{
@ -912,7 +912,7 @@ uint64_t nano::difficulty::from_multiplier (double const multiplier_a, uint64_t
double nano::difficulty::to_multiplier (uint64_t const difficulty_a, uint64_t const base_difficulty_a)
{
assert (difficulty_a > 0);
debug_assert (difficulty_a > 0);
return static_cast<double> (-base_difficulty_a) / (-difficulty_a);
}

View file

@ -1,6 +1,5 @@
#include <nano/lib/utility.hpp>
#include <cassert>
#include <cstring>
#include <fcntl.h>
@ -15,7 +14,7 @@ namespace
int create_load_memory_address_file (dl_phdr_info * info, size_t, void *)
{
static int counter = 0;
assert (counter <= 99);
debug_assert (counter <= 99);
// Create filename
const char file_prefix[] = "nano_node_crash_load_address_dump_";
// Holds the filename prefix, a unique (max 2 digits) number and extension (null terminator is included in file_prefix size)
@ -30,7 +29,7 @@ int create_load_memory_address_file (dl_phdr_info * info, size_t, void *)
0
#endif
);
assert (file_descriptor);
debug_assert (file_descriptor);
if (file_descriptor)
{
// Write the name of shared library (can be empty for the executable)

View file

@ -2,8 +2,6 @@
#include <boost/filesystem.hpp>
#include <cassert>
// clang-format off
// Keep windows.h header at the top
#include <windows.h>
@ -17,7 +15,7 @@ void nano::set_umask ()
int oldMode;
auto result (_umask_s (_S_IWRITE | _S_IREAD, &oldMode));
assert (result == 0);
debug_assert (result == 0);
}
void nano::set_secure_perm_directory (boost::filesystem::path const & path)

View file

@ -1,7 +1,7 @@
#pragma once
#include <cassert>
#include <nano/lib/utility.hpp>
#include <streambuf>
namespace nano
@ -33,6 +33,6 @@ void write (nano::stream & stream_a, T const & value)
static_assert (std::is_standard_layout<T>::value, "Can't stream write non-standard layout types");
auto amount_written (stream_a.sputn (reinterpret_cast<uint8_t const *> (&value), sizeof (value)));
(void)amount_written;
assert (amount_written == sizeof (value));
debug_assert (amount_written == sizeof (value));
}
}

View file

@ -80,7 +80,7 @@ std::string nano::thread_role::get_string (nano::thread_role::name role)
* length supported by the platforms we support
* (specifically, Linux)
*/
assert (thread_role_name_string.size () < 16);
debug_assert (thread_role_name_string.size () < 16);
return (thread_role_name_string);
}

View file

@ -1,6 +1,6 @@
#include <nano/lib/timer.hpp>
#include <nano/lib/utility.hpp>
#include <cassert>
#include <iomanip>
#include <sstream>
@ -91,7 +91,7 @@ nano::timer<UNIT, CLOCK> & nano::timer<UNIT, CLOCK>::start_child (std::string co
template <typename UNIT, typename CLOCK>
void nano::timer<UNIT, CLOCK>::start ()
{
assert (state == nano::timer_state::stopped);
debug_assert (state == nano::timer_state::stopped);
state = nano::timer_state::started;
begin = CLOCK::now ();
}
@ -115,7 +115,7 @@ UNIT nano::timer<UNIT, CLOCK>::pause ()
template <typename UNIT, typename CLOCK>
UNIT nano::timer<UNIT, CLOCK>::stop ()
{
assert (state == nano::timer_state::started);
debug_assert (state == nano::timer_state::started);
state = nano::timer_state::stopped;
auto end = CLOCK::now ();

View file

@ -299,7 +299,7 @@ nano::tomlconfig & nano::tomlconfig::get_config (bool optional, std::string cons
void nano::tomlconfig::erase_defaults (std::shared_ptr<cpptoml::table> base, std::shared_ptr<cpptoml::table> other, std::shared_ptr<cpptoml::table> update_target)
{
std::vector<std::string> erased;
assert (other != nullptr);
debug_assert (other != nullptr);
for (auto & item : *other)
{
std::string const & key = item.first;

View file

@ -5,6 +5,7 @@
#include <iostream>
#include <sstream>
#include <thread>
// Some builds (mac) fail due to "Boost.Stacktrace requires `_Unwind_Backtrace` function".
#ifndef _WIN32
@ -105,20 +106,21 @@ void nano::move_all_files_to_dir (boost::filesystem::path const & from, boost::f
}
/*
* Backing code for "release_assert", which is itself a macro
* Backing code for "release_assert" & "debug_assert", which are macros
*/
void release_assert_internal (bool check, const char * check_expr, const char * file, unsigned int line)
void assert_internal (const char * check_expr, const char * file, unsigned int line, bool is_release_assert)
{
if (check)
{
return;
}
std::cerr << "Assertion (" << check_expr << ") failed " << file << ":" << line << "\n\n";
// Output stack trace to cerr
// Output stack trace
auto backtrace_str = nano::generate_stacktrace ();
// Windows on Actions only outputs the first line of the stacktrace from standard error, use standard output
#if (defined(_WIN32) && CI)
std::cout << backtrace_str << std::endl;
#else
std::cerr << backtrace_str << std::endl;
#endif
std::cerr << "Assertion (" << check_expr << ") failed " << file << ":" << line << "\n"
<< std::endl;
// "abort" at the end of this function will go into any signal handlers (the daemon ones will generate a stack trace and load memory address files on non-Windows systems).
// As there is no async-signal-safe way to generate stacktraces on Windows it must be done before aborting
@ -127,7 +129,7 @@ void release_assert_internal (bool check, const char * check_expr, const char *
// Try construct the stacktrace dump in the same folder as the the running executable, otherwise use the current directory.
boost::system::error_code err;
auto running_executable_filepath = boost::dll::program_location (err);
std::string filename = "nano_node_backtrace_release_assert.txt";
std::string filename = is_release_assert ? "nano_node_backtrace_release_assert.txt" : "nano_node_backtrace_assert.txt";
std::string filepath = filename;
if (!err)
{
@ -139,5 +141,6 @@ void release_assert_internal (bool check, const char * check_expr, const char *
file << backtrace_str;
}
#endif
abort ();
}

View file

@ -20,6 +20,15 @@ namespace system
}
}
void assert_internal (const char * check_expr, const char * file, unsigned int line, bool is_release_assert);
#define release_assert(check) check ? (void)0 : assert_internal (#check, __FILE__, __LINE__, true)
#ifdef NDEBUG
#define debug_assert(check) (void)0
#else
#define debug_assert(check) check ? (void)0 : assert_internal (#check, __FILE__, __LINE__, false)
#endif
namespace nano
{
/* These containers are used to collect information about sequence containers.
@ -168,10 +177,7 @@ template <typename TARGET_TYPE, typename SOURCE_TYPE>
constexpr TARGET_TYPE narrow_cast (SOURCE_TYPE const & val)
{
auto res (static_cast<TARGET_TYPE> (val));
assert (val == static_cast<SOURCE_TYPE> (res));
debug_assert (val == static_cast<SOURCE_TYPE> (res));
return res;
}
}
void release_assert_internal (bool check, const char * check_expr, const char * file, unsigned int line);
#define release_assert(check) release_assert_internal (check, #check, __FILE__, __LINE__)

View file

@ -5,7 +5,7 @@
nano::wallet_config::wallet_config ()
{
nano::random_pool::generate_block (wallet.bytes.data (), wallet.bytes.size ());
assert (!wallet.is_zero ());
debug_assert (!wallet.is_zero ());
}
nano::error nano::wallet_config::parse (std::string const & wallet_a, std::string const & account_a)

View file

@ -35,7 +35,7 @@ bool nano::work_validate (nano::work_version const version_a, nano::root const &
invalid = nano::work_v1::validate (root_a, work_a, difficulty_a);
break;
default:
assert (false && "Invalid version specified to work_validate");
debug_assert (false && "Invalid version specified to work_validate");
}
return invalid;
}
@ -48,7 +48,7 @@ bool nano::work_validate (nano::block const & block_a, uint64_t * difficulty_a)
bool nano::work_validate (nano::root const & root_a, uint64_t const work_a, uint64_t * difficulty_a)
{
static nano::network_constants network_constants;
assert (network_constants.is_test_network ());
debug_assert (network_constants.is_test_network ());
return nano::work_validate (nano::work_version::work_1, root_a, work_a, difficulty_a);
}
@ -80,7 +80,7 @@ uint64_t nano::work_v1::value (nano::root const & root_a, uint64_t work_a)
static nano::network_constants network_constants;
if (!network_constants.is_test_network ())
{
assert (false);
debug_assert (false);
std::exit (1);
}
return network_constants.publish_threshold + 1;
@ -186,8 +186,8 @@ void nano::work_pool::loop (uint64_t thread)
if (ticket == ticket_l)
{
// If the ticket matches what we started with, we're the ones that found the solution
assert (output >= current_l.difficulty);
assert (current_l.difficulty == 0 || nano::work_v1::value (current_l.item, work) == output);
debug_assert (output >= current_l.difficulty);
debug_assert (current_l.difficulty == 0 || nano::work_v1::value (current_l.item, work) == output);
// Signal other threads to stop their work next time they check ticket
++ticket;
pending.pop_front ();
@ -262,7 +262,7 @@ void nano::work_pool::generate (nano::root const & root_a, std::function<void(bo
void nano::work_pool::generate (nano::work_version const version_a, nano::root const & root_a, std::function<void(boost::optional<uint64_t> const &)> callback_a, uint64_t difficulty_a)
{
assert (!root_a.is_zero ());
debug_assert (!root_a.is_zero ());
if (!threads.empty ())
{
{
@ -280,7 +280,7 @@ void nano::work_pool::generate (nano::work_version const version_a, nano::root c
boost::optional<uint64_t> nano::work_pool::generate (nano::root const & root_a)
{
static nano::network_constants network_constants;
assert (network_constants.is_test_network ());
debug_assert (network_constants.is_test_network ());
return generate (nano::work_version::work_1, root_a);
}
@ -292,7 +292,7 @@ boost::optional<uint64_t> nano::work_pool::generate (nano::work_version const ve
boost::optional<uint64_t> nano::work_pool::generate (nano::root const & root_a, uint64_t difficulty_a)
{
static nano::network_constants network_constants;
assert (network_constants.is_test_network ());
debug_assert (network_constants.is_test_network ());
return generate (nano::work_version::work_1, root_a, difficulty_a);
}

View file

@ -450,7 +450,7 @@ int main (int argc, char * const * argv)
#else
std::thread processes_thread ([&data_paths, &node_path, &rpc_path, &current_network]() {
auto formatted_command = "%1% --daemon --data_path=%2% --network=%3% %4%";
assert (!data_paths.empty ());
ASSERT_TRUE (!data_paths.empty ());
for (int i = 0; i < data_paths.size (); ++i)
{
auto node_exe_command = boost::str (boost::format (formatted_command) % node_path % data_paths[i].string () % current_network % "&");
@ -474,7 +474,7 @@ int main (int argc, char * const * argv)
boost::asio::io_context ioc;
assert (!nano::signal_handler_impl);
debug_assert (!nano::signal_handler_impl);
nano::signal_handler_impl = [&ioc]() {
ioc.stop ();
};

View file

@ -136,7 +136,7 @@ void nano_daemon::daemon::run (boost::filesystem::path const & data_path, nano::
}
}
assert (!nano::signal_handler_impl);
debug_assert (!nano::signal_handler_impl);
nano::signal_handler_impl = [&io_ctx]() {
io_ctx.stop ();
sig_int_or_term = 1;

View file

@ -203,7 +203,7 @@ int main (int argc, char * const * argv)
auto weekly_distribution (yearly_distribution / 52);
for (auto j (0); j != 52; ++j)
{
assert (balance > weekly_distribution);
debug_assert (balance > weekly_distribution);
balance = balance < (weekly_distribution * 2) ? 0 : balance - weekly_distribution;
nano::send_block send (previous, landing.pub, balance, genesis.prv, genesis.pub, *work.generate (nano::work_version::work_1, previous));
previous = send.hash ();

View file

@ -52,7 +52,7 @@ void run (boost::filesystem::path const & data_path, std::vector<std::string> co
auto rpc = nano::get_rpc (io_ctx, rpc_config, ipc_rpc_processor);
rpc->start ();
assert (!nano::signal_handler_impl);
debug_assert (!nano::signal_handler_impl);
nano::signal_handler_impl = [&io_ctx]() {
io_ctx.stop ();
sig_int_or_term = 1;

View file

@ -143,7 +143,7 @@ int run_wallet (QApplication & application, int argc, char * const * argv, boost
wallet_config.account = wallet->deterministic_insert (transaction);
}
}
assert (wallet->exists (wallet_config.account));
debug_assert (wallet->exists (wallet_config.account));
write_wallet_config (wallet_config, data_path);
node->start ();
nano::ipc::ipc_server ipc (*node, config.rpc);

View file

@ -38,8 +38,8 @@ thread ([this]() {
this->cemented_batch_finished_callback ();
});
assert (min_time_between_requests > std::chrono::milliseconds (node.network_params.network.request_interval_ms));
assert (min_time_between_floods > std::chrono::milliseconds (node.network_params.network.request_interval_ms));
debug_assert (min_time_between_requests > std::chrono::milliseconds (node.network_params.network.request_interval_ms));
debug_assert (min_time_between_floods > std::chrono::milliseconds (node.network_params.network.request_interval_ms));
nano::unique_lock<std::mutex> lock (mutex);
condition.wait (lock, [& started = started] { return started; });
}
@ -259,7 +259,7 @@ void nano::active_transactions::election_escalate (std::shared_ptr<nano::electio
void nano::active_transactions::request_confirm (nano::unique_lock<std::mutex> & lock_a)
{
assert (!mutex.try_lock ());
debug_assert (!mutex.try_lock ());
auto transaction_l (node.store.tx_begin_read ());
std::unordered_set<nano::qualified_root> inactive_l;
/*
@ -410,7 +410,7 @@ void nano::active_transactions::prioritize_account_for_confirmation (nano::activ
}
else
{
assert (cementable_frontiers_size_a <= max_priority_cementable_frontiers);
debug_assert (cementable_frontiers_size_a <= max_priority_cementable_frontiers);
if (cementable_frontiers_size_a == max_priority_cementable_frontiers)
{
// The maximum amount of frontiers stored has been reached. Check if the current frontier
@ -681,7 +681,7 @@ void nano::active_transactions::update_difficulty (std::shared_ptr<nano::block>
uint64_t difficulty;
auto error (nano::work_validate (nano::work_version::work_1, *block_a, &difficulty));
(void)error;
assert (!error);
debug_assert (!error);
if (difficulty > existing_election->difficulty)
{
if (node.config.logging.active_update_logging ())
@ -734,7 +734,7 @@ void nano::active_transactions::update_difficulty (std::shared_ptr<nano::block>
void nano::active_transactions::adjust_difficulty (nano::block_hash const & hash_a)
{
assert (!mutex.try_lock ());
debug_assert (!mutex.try_lock ());
std::deque<std::pair<nano::block_hash, int64_t>> remaining_blocks;
remaining_blocks.emplace_back (hash_a, 0);
std::unordered_set<nano::block_hash> processed_blocks;
@ -801,13 +801,13 @@ void nano::active_transactions::adjust_difficulty (nano::block_hash const & hash
{
// Highest adjusted difficulty value should be std::numeric_limits<std::uint64_t>::max ()
limiter = std::numeric_limits<std::uint64_t>::max () - average + highest_level;
assert (std::numeric_limits<std::uint64_t>::max () == average + highest_level - limiter);
debug_assert (std::numeric_limits<std::uint64_t>::max () == average + highest_level - limiter);
}
else if (average < std::numeric_limits<std::uint64_t>::min () - lowest_level)
{
// Lowest adjusted difficulty value should be std::numeric_limits<std::uint64_t>::min ()
limiter = std::numeric_limits<std::uint64_t>::min () - average + lowest_level;
assert (std::numeric_limits<std::uint64_t>::min () == average + lowest_level - limiter);
debug_assert (std::numeric_limits<std::uint64_t>::min () == average + lowest_level - limiter);
}
// Set adjusted difficulty
@ -824,7 +824,7 @@ void nano::active_transactions::adjust_difficulty (nano::block_hash const & hash
void nano::active_transactions::update_active_difficulty (nano::unique_lock<std::mutex> & lock_a)
{
assert (!mutex.try_lock ());
debug_assert (!mutex.try_lock ());
double multiplier (1.);
if (!roots.empty ())
{
@ -845,11 +845,11 @@ void nano::active_transactions::update_active_difficulty (nano::unique_lock<std:
multiplier = nano::difficulty::to_multiplier (active_root_difficulties[active_root_difficulties.size () / 2], node.network_params.network.publish_threshold);
}
}
assert (multiplier >= 1);
debug_assert (multiplier >= 1);
multipliers_cb.push_front (multiplier);
auto sum (std::accumulate (multipliers_cb.begin (), multipliers_cb.end (), double(0)));
auto difficulty = nano::difficulty::from_multiplier (sum / multipliers_cb.size (), node.network_params.network.publish_threshold);
assert (difficulty >= node.network_params.network.publish_threshold);
debug_assert (difficulty >= node.network_params.network.publish_threshold);
trended_active_difficulty = difficulty;
node.observers.difficulty.notify (trended_active_difficulty);
@ -1116,7 +1116,7 @@ size_t nano::active_transactions::dropped_elections_cache_size ()
void nano::active_transactions::add_dropped_elections_cache (nano::qualified_root const & root_a)
{
assert (!mutex.try_lock ());
debug_assert (!mutex.try_lock ());
dropped_elections_cache.get<tag_sequence> ().emplace_back (nano::election_timepoint{ std::chrono::steady_clock::now (), root_a });
if (dropped_elections_cache.size () > dropped_elections_cache_max)
{
@ -1126,7 +1126,7 @@ void nano::active_transactions::add_dropped_elections_cache (nano::qualified_roo
std::chrono::steady_clock::time_point nano::active_transactions::find_dropped_elections_cache (nano::qualified_root const & root_a)
{
assert (!mutex.try_lock ());
debug_assert (!mutex.try_lock ());
auto existing (dropped_elections_cache.get<tag_root> ().find (root_a));
if (existing != dropped_elections_cache.get<tag_root> ().end ())
{

View file

@ -5,8 +5,6 @@
#include <boost/format.hpp>
#include <cassert>
std::chrono::milliseconds constexpr nano::block_processor::confirmation_request_delay;
nano::block_processor::block_processor (nano::node & node_a, nano::write_database_queue & write_database_queue_a) :
@ -93,7 +91,7 @@ void nano::block_processor::add (nano::unchecked_info const & info_a)
else
{
node.logger.try_log ("nano::block_processor::add called for hash ", info_a.block->hash ().to_string (), " with invalid work ", nano::to_string_hex (info_a.block->block_work ()));
assert (false && "nano::block_processor::add called with invalid work");
debug_assert (false && "nano::block_processor::add called with invalid work");
}
}
@ -147,13 +145,13 @@ bool nano::block_processor::should_log (bool first_time)
bool nano::block_processor::have_blocks ()
{
assert (!mutex.try_lock ());
debug_assert (!mutex.try_lock ());
return !blocks.empty () || !forced.empty () || !state_blocks.empty ();
}
void nano::block_processor::verify_state_blocks (nano::unique_lock<std::mutex> & lock_a, size_t max_count)
{
assert (!mutex.try_lock ());
debug_assert (!mutex.try_lock ());
nano::timer<std::chrono::milliseconds> timer_l (nano::timer_state::started);
std::deque<nano::unchecked_info> items;
if (state_blocks.size () <= max_count)
@ -167,7 +165,7 @@ void nano::block_processor::verify_state_blocks (nano::unique_lock<std::mutex> &
items.push_back (state_blocks.front ());
state_blocks.pop_front ();
}
assert (!state_blocks.empty ());
debug_assert (!state_blocks.empty ());
}
lock_a.unlock ();
if (!items.empty ())
@ -214,7 +212,7 @@ void nano::block_processor::verify_state_blocks (nano::unique_lock<std::mutex> &
lock_a.lock ();
for (auto i (0); i < size; ++i)
{
assert (verifications[i] == 1 || verifications[i] == 0);
debug_assert (verifications[i] == 1 || verifications[i] == 0);
auto & item (items.front ());
if (!item.block->link ().is_zero () && node.ledger.is_epoch_link (item.block->link ()))
{
@ -556,7 +554,7 @@ void nano::block_processor::queue_unchecked (nano::write_transaction const & tra
{
if (!node.store.unchecked_del (transaction_a, nano::unchecked_key (hash_a, info.block->hash ())))
{
assert (node.ledger.cache.unchecked_count > 0);
debug_assert (node.ledger.cache.unchecked_count > 0);
--node.ledger.cache.unchecked_count;
}
}
@ -580,7 +578,7 @@ nano::block_hash nano::block_processor::filter_item (nano::block_hash const & ha
void nano::block_processor::requeue_invalid (nano::block_hash const & hash_a, nano::unchecked_info const & info_a)
{
assert (hash_a == info_a.block->hash ());
debug_assert (hash_a == info_a.block->hash ());
auto attempt (node.bootstrap_initiator.current_attempt ());
if (attempt != nullptr && attempt->mode == nano::bootstrap_mode::lazy)
{

View file

@ -217,7 +217,7 @@ void nano::bootstrap_attempt::request_push (nano::unique_lock<std::mutex> & lock
bool nano::bootstrap_attempt::still_pulling ()
{
assert (!mutex.try_lock ());
debug_assert (!mutex.try_lock ());
auto running (!stopped);
auto more_pulls (!pulls.empty ());
auto still_pulling (pulling > 0);
@ -254,7 +254,7 @@ void nano::bootstrap_attempt::run_start (nano::unique_lock<std::mutex> & lock_a)
void nano::bootstrap_attempt::run ()
{
assert (!node->flags.disable_legacy_bootstrap);
debug_assert (!node->flags.disable_legacy_bootstrap);
start_populate_connections ();
nano::unique_lock<std::mutex> lock (mutex);
run_start (lock);
@ -612,7 +612,7 @@ void nano::bootstrap_attempt::requeue_pull (nano::pull_info const & pull_a, bool
}
else if (mode == nano::bootstrap_mode::lazy && (pull.retry_limit == std::numeric_limits<unsigned>::max () || pull.attempts <= pull.retry_limit + (pull.processed / node->network_params.bootstrap.lazy_max_pull_blocks)))
{
assert (pull.account_or_head == pull.head);
debug_assert (pull.account_or_head == pull.head);
if (!lazy_processed_or_exists (pull.account_or_head))
{
// Retry for lazy pulls
@ -632,7 +632,7 @@ void nano::bootstrap_attempt::requeue_pull (nano::pull_info const & pull_a, bool
node->bootstrap_initiator.cache.add (pull);
if (mode == nano::bootstrap_mode::lazy && pull.processed > 0)
{
assert (pull.account_or_head == pull.head);
debug_assert (pull.account_or_head == pull.head);
nano::lock_guard<std::mutex> lazy_lock (lazy_mutex);
lazy_add (pull.account_or_head, pull.retry_limit);
}
@ -654,7 +654,7 @@ void nano::bootstrap_attempt::attempt_restart_check (nano::unique_lock<std::mute
if (!frontiers_confirmed && (requeued_pulls > (!node->network_params.network.is_test_network () ? nano::bootstrap_limits::requeued_pulls_limit : nano::bootstrap_limits::requeued_pulls_limit_test) || total_blocks > nano::bootstrap_limits::frontier_confirmation_blocks_limit))
{
auto confirmed (confirm_frontiers (lock_a));
assert (lock_a.owns_lock ());
debug_assert (lock_a.owns_lock ());
if (!confirmed)
{
node->stats.inc (nano::stat::type::bootstrap, nano::stat::detail::frontier_confirmation_failed, nano::stat::dir::in);
@ -683,7 +683,7 @@ void nano::bootstrap_attempt::attempt_restart_check (nano::unique_lock<std::mute
bool nano::bootstrap_attempt::confirm_frontiers (nano::unique_lock<std::mutex> & lock_a)
{
bool confirmed (false);
assert (!frontiers_confirmed);
debug_assert (!frontiers_confirmed);
condition.wait (lock_a, [& stopped = stopped] { return !stopped; });
std::vector<nano::block_hash> frontiers;
for (auto i (pulls.begin ()), end (pulls.end ()); i != end && frontiers.size () != nano::bootstrap_limits::bootstrap_max_confirm_frontiers; ++i)
@ -842,7 +842,7 @@ void nano::bootstrap_attempt::lazy_start (nano::hash_or_account const & hash_or_
void nano::bootstrap_attempt::lazy_add (nano::hash_or_account const & hash_or_account_a, unsigned retry_limit)
{
// Add only unknown blocks
assert (!lazy_mutex.try_lock ());
debug_assert (!lazy_mutex.try_lock ());
if (lazy_blocks.find (hash_or_account_a) == lazy_blocks.end ())
{
lazy_pulls.emplace_back (hash_or_account_a, retry_limit);
@ -864,13 +864,13 @@ void nano::bootstrap_attempt::lazy_requeue (nano::block_hash const & hash_a, nan
void nano::bootstrap_attempt::lazy_pull_flush ()
{
assert (!mutex.try_lock ());
debug_assert (!mutex.try_lock ());
static size_t const max_pulls (nano::bootstrap_limits::bootstrap_connection_scale_target_blocks_lazy * 3);
if (pulls.size () < max_pulls)
{
last_lazy_flush = std::chrono::steady_clock::now ();
nano::lock_guard<std::mutex> lazy_lock (lazy_mutex);
assert (node->network_params.bootstrap.lazy_max_pull_blocks <= std::numeric_limits<nano::pull_info::count_t>::max ());
debug_assert (node->network_params.bootstrap.lazy_max_pull_blocks <= std::numeric_limits<nano::pull_info::count_t>::max ());
nano::pull_info::count_t batch_count (node->network_params.bootstrap.lazy_max_pull_blocks);
if (total_blocks > nano::bootstrap_limits::lazy_batch_pull_count_resize_blocks_limit && !lazy_blocks.empty ())
{
@ -968,7 +968,7 @@ bool nano::bootstrap_attempt::lazy_has_expired () const
void nano::bootstrap_attempt::lazy_clear ()
{
assert (!lazy_mutex.try_lock ());
debug_assert (!lazy_mutex.try_lock ());
lazy_blocks.clear ();
lazy_blocks_count = 0;
lazy_keys.clear ();
@ -980,7 +980,7 @@ void nano::bootstrap_attempt::lazy_clear ()
void nano::bootstrap_attempt::lazy_run ()
{
assert (!node->flags.disable_lazy_bootstrap);
debug_assert (!node->flags.disable_lazy_bootstrap);
start_populate_connections ();
lazy_start_time = std::chrono::steady_clock::now ();
nano::unique_lock<std::mutex> lock (mutex);
@ -1335,7 +1335,7 @@ void nano::bootstrap_attempt::wallet_start (std::deque<nano::account> & accounts
bool nano::bootstrap_attempt::wallet_finished ()
{
assert (!mutex.try_lock ());
debug_assert (!mutex.try_lock ());
auto running (!stopped);
auto more_accounts (!wallet_accounts.empty ());
auto still_pulling (pulling > 0);
@ -1344,7 +1344,7 @@ bool nano::bootstrap_attempt::wallet_finished ()
void nano::bootstrap_attempt::wallet_run ()
{
assert (!node->flags.disable_wallet_bootstrap);
debug_assert (!node->flags.disable_wallet_bootstrap);
start_populate_connections ();
auto start_time (std::chrono::steady_clock::now ());
auto max_time (std::chrono::minutes (10));
@ -1594,7 +1594,7 @@ void nano::pulls_cache::add (nano::pull_info const & pull_a)
{
cache.erase (cache.begin ());
}
assert (cache.size () <= cache_size_max);
debug_assert (cache.size () <= cache_size_max);
nano::uint512_union head_512 (pull_a.account_or_head, pull_a.head_original);
auto existing (cache.get<account_head_tag> ().find (head_512));
if (existing == cache.get<account_head_tag> ().end ())
@ -1602,7 +1602,7 @@ void nano::pulls_cache::add (nano::pull_info const & pull_a)
// Insert new pull
auto inserted (cache.emplace (nano::cached_pulls{ std::chrono::steady_clock::now (), head_512, pull_a.head }));
(void)inserted;
assert (inserted.second);
debug_assert (inserted.second);
}
else
{
@ -1642,14 +1642,14 @@ uint64_t nano::bootstrap_excluded_peers::add (nano::tcp_endpoint const & endpoin
{
peers.erase (peers.begin ());
}
assert (peers.size () <= excluded_peers_size_max);
debug_assert (peers.size () <= excluded_peers_size_max);
auto existing (peers.get<endpoint_tag> ().find (endpoint_a));
if (existing == peers.get<endpoint_tag> ().end ())
{
// Insert new endpoint
auto inserted (peers.emplace (nano::excluded_peers_item{ std::chrono::steady_clock::steady_clock::now () + exclude_time_hours, endpoint_a, 1 }));
(void)inserted;
assert (inserted.second);
debug_assert (inserted.second);
result = 1;
}
else

View file

@ -55,7 +55,7 @@ nano::bulk_pull_client::~bulk_pull_client ()
void nano::bulk_pull_client::request ()
{
assert (!pull.head.is_zero () || pull.retry_limit != std::numeric_limits<unsigned>::max ());
debug_assert (!pull.head.is_zero () || pull.retry_limit != std::numeric_limits<unsigned>::max ());
expected = pull.head;
nano::bulk_pull req;
if (pull.head == pull.head_original && pull.attempts % 4 < 3)
@ -103,7 +103,7 @@ void nano::bulk_pull_client::request ()
void nano::bulk_pull_client::throttled_receive_block ()
{
assert (!network_error);
debug_assert (!network_error);
if (!connection->node->block_processor.half_full ())
{
receive_block ();
@ -352,12 +352,12 @@ void nano::bulk_pull_account_client::receive_pending ()
nano::bufferstream frontier_stream (this_l->connection->receive_buffer->data (), sizeof (nano::uint256_union));
auto error1 (nano::try_read (frontier_stream, pending));
(void)error1;
assert (!error1);
debug_assert (!error1);
nano::amount balance;
nano::bufferstream balance_stream (this_l->connection->receive_buffer->data () + sizeof (nano::uint256_union), sizeof (nano::uint128_union));
auto error2 (nano::try_read (balance_stream, balance));
(void)error2;
assert (!error2);
debug_assert (!error2);
if (this_l->pull_blocks == 0 || !pending.is_zero ())
{
if (this_l->pull_blocks == 0 || balance.number () >= this_l->connection->node->config.receive_minimum.number ())
@ -423,7 +423,7 @@ void nano::bulk_pull_account_client::receive_pending ()
void nano::bulk_pull_server::set_current_end ()
{
include_start = false;
assert (request != nullptr);
debug_assert (request != nullptr);
auto transaction (connection->node->store.tx_begin_read ());
if (!connection->node->store.block_exists (transaction, request->end))
{
@ -613,7 +613,7 @@ void nano::bulk_pull_server::no_block_sent (boost::system::error_code const & ec
{
if (!ec)
{
assert (size_a == 1);
debug_assert (size_a == 1);
connection->finish_request ();
}
else
@ -637,7 +637,7 @@ request (std::move (request_a))
*/
void nano::bulk_pull_account_server::set_params ()
{
assert (request != nullptr);
debug_assert (request != nullptr);
/*
* Parse the flags
@ -920,17 +920,17 @@ void nano::bulk_pull_account_server::complete (boost::system::error_code const &
{
if (pending_address_only)
{
assert (size_a == 32);
debug_assert (size_a == 32);
}
else
{
if (pending_include_address)
{
assert (size_a == 80);
debug_assert (size_a == 80);
}
else
{
assert (size_a == 48);
debug_assert (size_a == 48);
}
}

View file

@ -92,17 +92,17 @@ void nano::frontier_req_client::received_frontier (boost::system::error_code con
{
if (!ec)
{
assert (size_a == nano::frontier_req_client::size_frontier);
debug_assert (size_a == nano::frontier_req_client::size_frontier);
nano::account account;
nano::bufferstream account_stream (connection->receive_buffer->data (), sizeof (account));
auto error1 (nano::try_read (account_stream, account));
(void)error1;
assert (!error1);
debug_assert (!error1);
nano::block_hash latest;
nano::bufferstream latest_stream (connection->receive_buffer->data () + sizeof (account), sizeof (latest));
auto error2 (nano::try_read (latest_stream, latest));
(void)error2;
assert (!error2);
debug_assert (!error2);
if (count == 0)
{
start_time = std::chrono::steady_clock::now ();
@ -157,7 +157,7 @@ void nano::frontier_req_client::received_frontier (boost::system::error_code con
}
else
{
assert (account < current);
debug_assert (account < current);
connection->attempt->add_pull (nano::pull_info (account, latest, nano::block_hash (0), 0, connection->node->network_params.bootstrap.frontier_retry_limit));
}
}

View file

@ -24,7 +24,7 @@ void nano::bootstrap_listener::start ()
node.logger.try_log (boost::str (boost::format ("Error while binding for incoming TCP/bootstrap on port %1%: %2%") % listening_socket->listening_port () % ec.message ()));
throw std::runtime_error (ec.message ());
}
assert (node.network.endpoint ().port () == listening_socket->listening_port ());
debug_assert (node.network.endpoint ().port () == listening_socket->listening_port ());
listening_socket->on_connection ([this](std::shared_ptr<nano::socket> new_connection, boost::system::error_code const & ec_a) {
bool keep_accepting = true;
if (ec_a)
@ -160,7 +160,7 @@ void nano::bootstrap_server::receive_header_action (boost::system::error_code co
{
if (!ec)
{
assert (size_a == 8);
debug_assert (size_a == 8);
nano::bufferstream type_stream (receive_buffer->data (), size_a);
auto error (false);
nano::message_header header (error, type_stream);
@ -307,7 +307,7 @@ void nano::bootstrap_server::receive_bulk_pull_account_action (boost::system::er
if (!ec)
{
auto error (false);
assert (size_a == header_a.payload_length_bytes ());
debug_assert (size_a == header_a.payload_length_bytes ());
nano::bufferstream stream (receive_buffer->data (), size_a);
auto request (std::make_unique<nano::bulk_pull_account> (error, stream, header_a));
if (!error)
@ -497,7 +497,7 @@ void nano::bootstrap_server::receive_node_id_handshake_action (boost::system::er
void nano::bootstrap_server::add_request (std::unique_ptr<nano::message> message_a)
{
assert (message_a != nullptr);
debug_assert (message_a != nullptr);
nano::lock_guard<std::mutex> lock (mutex);
auto start (requests.empty ());
requests.push (std::move (message_a));
@ -648,7 +648,7 @@ public:
if (message_a.query)
{
boost::optional<std::pair<nano::account, nano::signature>> response (std::make_pair (connection->node->node_id.pub, nano::sign_message (connection->node->node_id.prv, connection->node->node_id.pub, *message_a.query)));
assert (!nano::validate_message (response->first, *message_a.query, response->second));
debug_assert (!nano::validate_message (response->first, *message_a.query, response->second));
auto cookie (connection->node->network.syn_cookies.assign (nano::transport::map_tcp_to_endpoint (connection->remote_endpoint)));
nano::node_id_handshake response_message (cookie, response);
auto shared_const_buffer = response_message.to_shared_const_buffer ();
@ -694,7 +694,7 @@ public:
}
nano::account node_id (connection->remote_node_id);
nano::bootstrap_server_type type (connection->type);
assert (node_id.is_zero () || type == nano::bootstrap_server_type::realtime);
debug_assert (node_id.is_zero () || type == nano::bootstrap_server_type::realtime);
auto connection_l (connection->shared_from_this ());
connection->node->background ([connection_l, message_a, node_id, type]() {
connection_l->node->network.tcp_channels.process_message (message_a, connection_l->remote_endpoint, node_id, connection_l->socket, type);
@ -706,7 +706,7 @@ public:
void nano::bootstrap_server::run_next ()
{
assert (!requests.empty ());
debug_assert (!requests.empty ());
request_response_visitor visitor (shared_from_this ());
requests.front ()->visit (visitor);
}

View file

@ -836,7 +836,7 @@ std::error_code nano::handle_node_options (boost::program_options::variables_map
nano::raw_key key;
auto error (existing->second->store.fetch (transaction, account, key));
(void)error;
assert (!error);
debug_assert (!error);
std::cout << boost::str (boost::format ("Pub: %1% Prv: %2%\n") % account.to_account () % key.data.to_string ());
if (nano::pub_key (key.as_private_key ()) != account)
{

View file

@ -31,7 +31,7 @@ nano::protocol_constants const & get_protocol_constants ()
uint64_t nano::ip_address_hash_raw (boost::asio::ip::address const & ip_a, uint16_t port)
{
static nano::random_constants constants;
assert (ip_a.is_v6 ());
debug_assert (ip_a.is_v6 ());
uint64_t result;
nano::uint128_union address;
address.bytes = ip_a.to_v6 ().to_bytes ();
@ -144,7 +144,7 @@ uint8_t nano::message_header::count_get () const
void nano::message_header::count_set (uint8_t count_a)
{
assert (count_a < 16);
debug_assert (count_a < 16);
extensions &= ~count_mask;
extensions |= std::bitset<16> (static_cast<unsigned long long> (count_a) << 12);
}
@ -152,7 +152,7 @@ void nano::message_header::count_set (uint8_t count_a)
void nano::message_header::flag_set (uint8_t flag_a)
{
// Flags from 8 are block_type & count
assert (flag_a < 8);
debug_assert (flag_a < 8);
extensions.set (flag_a, true);
}
@ -243,7 +243,7 @@ size_t nano::message_header::payload_length_bytes () const
}
default:
{
assert (false);
debug_assert (false);
return 0;
}
}
@ -314,7 +314,7 @@ std::string nano::message_parser::status_string ()
}
}
assert (false);
debug_assert (false);
return "[unknown parse_status]";
}
@ -561,7 +561,7 @@ void nano::keepalive::serialize (nano::stream & stream_a) const
header.serialize (stream_a);
for (auto i (peers.begin ()), j (peers.end ()); i != j; ++i)
{
assert (i->address ().is_v6 ());
debug_assert (i->address ().is_v6 ());
auto bytes (i->address ().to_v6 ().to_bytes ());
write (stream_a, bytes);
write (stream_a, i->port ());
@ -570,7 +570,7 @@ void nano::keepalive::serialize (nano::stream & stream_a) const
bool nano::keepalive::deserialize (nano::stream & stream_a)
{
assert (header.type == nano::message_type::keepalive);
debug_assert (header.type == nano::message_type::keepalive);
auto error (false);
for (auto i (peers.begin ()), j (peers.end ()); i != j && !error; ++i)
{
@ -611,14 +611,14 @@ block (block_a)
void nano::publish::serialize (nano::stream & stream_a) const
{
assert (block != nullptr);
debug_assert (block != nullptr);
header.serialize (stream_a);
block->serialize (stream_a);
}
bool nano::publish::deserialize (nano::stream & stream_a, nano::block_uniquer * uniquer_a)
{
assert (header.type == nano::message_type::publish);
debug_assert (header.type == nano::message_type::publish);
block = nano::deserialize_block (stream_a, header.block_type (), uniquer_a);
auto result (block == nullptr);
return result;
@ -656,7 +656,7 @@ roots_hashes (roots_hashes_a)
{
// not_a_block (1) block type for hashes + roots request
header.block_type_set (nano::block_type::not_a_block);
assert (roots_hashes.size () < 16);
debug_assert (roots_hashes.size () < 16);
header.count_set (static_cast<uint8_t> (roots_hashes.size ()));
}
@ -664,10 +664,10 @@ nano::confirm_req::confirm_req (nano::block_hash const & hash_a, nano::root cons
message (nano::message_type::confirm_req),
roots_hashes (std::vector<std::pair<nano::block_hash, nano::root>> (1, std::make_pair (hash_a, root_a)))
{
assert (!roots_hashes.empty ());
debug_assert (!roots_hashes.empty ());
// not_a_block (1) block type for hashes + roots request
header.block_type_set (nano::block_type::not_a_block);
assert (roots_hashes.size () < 16);
debug_assert (roots_hashes.size () < 16);
header.count_set (static_cast<uint8_t> (roots_hashes.size ()));
}
@ -681,7 +681,7 @@ void nano::confirm_req::serialize (nano::stream & stream_a) const
header.serialize (stream_a);
if (header.block_type () == nano::block_type::not_a_block)
{
assert (!roots_hashes.empty ());
debug_assert (!roots_hashes.empty ());
// Write hashes & roots
for (auto & root_hash : roots_hashes)
{
@ -691,7 +691,7 @@ void nano::confirm_req::serialize (nano::stream & stream_a) const
}
else
{
assert (block != nullptr);
debug_assert (block != nullptr);
block->serialize (stream_a);
}
}
@ -699,7 +699,7 @@ void nano::confirm_req::serialize (nano::stream & stream_a) const
bool nano::confirm_req::deserialize (nano::stream & stream_a, nano::block_uniquer * uniquer_a)
{
bool result (false);
assert (header.type == nano::message_type::confirm_req);
debug_assert (header.type == nano::message_type::confirm_req);
try
{
if (header.block_type () == nano::block_type::not_a_block)
@ -788,12 +788,12 @@ nano::confirm_ack::confirm_ack (std::shared_ptr<nano::vote> vote_a) :
message (nano::message_type::confirm_ack),
vote (vote_a)
{
assert (!vote_a->blocks.empty ());
debug_assert (!vote_a->blocks.empty ());
auto & first_vote_block (vote_a->blocks[0]);
if (first_vote_block.which ())
{
header.block_type_set (nano::block_type::not_a_block);
assert (vote_a->blocks.size () < 16);
debug_assert (vote_a->blocks.size () < 16);
header.count_set (static_cast<uint8_t> (vote_a->blocks.size ()));
}
else
@ -804,7 +804,7 @@ vote (vote_a)
void nano::confirm_ack::serialize (nano::stream & stream_a) const
{
assert (header.block_type () == nano::block_type::not_a_block || header.block_type () == nano::block_type::send || header.block_type () == nano::block_type::receive || header.block_type () == nano::block_type::open || header.block_type () == nano::block_type::change || header.block_type () == nano::block_type::state);
debug_assert (header.block_type () == nano::block_type::not_a_block || header.block_type () == nano::block_type::send || header.block_type () == nano::block_type::receive || header.block_type () == nano::block_type::open || header.block_type () == nano::block_type::change || header.block_type () == nano::block_type::state);
header.serialize (stream_a);
vote->serialize (stream_a, header.block_type ());
}
@ -858,7 +858,7 @@ void nano::frontier_req::serialize (nano::stream & stream_a) const
bool nano::frontier_req::deserialize (nano::stream & stream_a)
{
assert (header.type == nano::message_type::frontier_req);
debug_assert (header.type == nano::message_type::frontier_req);
auto error (false);
try
{
@ -913,7 +913,7 @@ void nano::bulk_pull::serialize (nano::stream & stream_a) const
* and that is the behavior of not having the flag set
* so it is wasteful to do this.
*/
assert ((count == 0 && !is_count_present ()) || (count != 0 && is_count_present ()));
debug_assert ((count == 0 && !is_count_present ()) || (count != 0 && is_count_present ()));
header.serialize (stream_a);
write (stream_a, start);
@ -934,7 +934,7 @@ void nano::bulk_pull::serialize (nano::stream & stream_a) const
bool nano::bulk_pull::deserialize (nano::stream & stream_a)
{
assert (header.type == nano::message_type::bulk_pull);
debug_assert (header.type == nano::message_type::bulk_pull);
auto error (false);
try
{
@ -1009,7 +1009,7 @@ void nano::bulk_pull_account::serialize (nano::stream & stream_a) const
bool nano::bulk_pull_account::deserialize (nano::stream & stream_a)
{
assert (header.type == nano::message_type::bulk_pull_account);
debug_assert (header.type == nano::message_type::bulk_pull_account);
auto error (false);
try
{
@ -1037,7 +1037,7 @@ message (header_a)
bool nano::bulk_push::deserialize (nano::stream & stream_a)
{
assert (header.type == nano::message_type::bulk_push);
debug_assert (header.type == nano::message_type::bulk_push);
return false;
}
@ -1063,7 +1063,7 @@ message (header_a)
bool nano::telemetry_req::deserialize (nano::stream & stream_a)
{
assert (header.type == nano::message_type::telemetry_req);
debug_assert (header.type == nano::message_type::telemetry_req);
return false;
}
@ -1123,7 +1123,7 @@ void nano::telemetry_ack::serialize (nano::stream & stream_a) const
bool nano::telemetry_ack::deserialize (nano::stream & stream_a)
{
auto error (false);
assert (header.type == nano::message_type::telemetry_ack);
debug_assert (header.type == nano::message_type::telemetry_ack);
try
{
if (!is_empty_payload ())
@ -1289,7 +1289,7 @@ void nano::node_id_handshake::serialize (nano::stream & stream_a) const
bool nano::node_id_handshake::deserialize (nano::stream & stream_a)
{
assert (header.type == nano::message_type::node_id_handshake);
debug_assert (header.type == nano::message_type::node_id_handshake);
auto error (false);
try
{

View file

@ -67,7 +67,7 @@ void nano::confirmation_height_bounded::process ()
auto top_level_hash = current;
nano::block_sideband sideband;
auto block = ledger.store.block_get (transaction, current, &sideband);
assert (block != nullptr);
debug_assert (block != nullptr);
nano::account account (block->account ());
if (account.is_zero ())
{
@ -85,7 +85,7 @@ void nano::confirmation_height_bounded::process ()
else
{
auto error = ledger.store.confirmation_height_get (transaction, account, confirmation_height_info);
assert (!error);
debug_assert (!error);
}
auto block_height = sideband.height;
@ -184,7 +184,7 @@ void nano::confirmation_height_bounded::process ()
transaction.refresh ();
} while ((!receive_source_pairs.empty () || current != original_hash) && !stopped);
assert (checkpoints.empty ());
debug_assert (checkpoints.empty ());
}
nano::block_hash nano::confirmation_height_bounded::get_least_unconfirmed_hash_from_top_level (nano::transaction const & transaction_a, nano::block_hash const & hash_a, nano::account const & account_a, nano::confirmation_height_info const & confirmation_height_info_a, uint64_t & block_height_a)
@ -344,10 +344,10 @@ bool nano::confirmation_height_bounded::cement_blocks ()
#ifndef NDEBUG
// Extra debug checks
nano::confirmation_height_info confirmation_height_info;
assert (!ledger.store.confirmation_height_get (transaction, account, confirmation_height_info));
debug_assert (!ledger.store.confirmation_height_get (transaction, account, confirmation_height_info));
nano::block_sideband sideband;
assert (ledger.store.block_get (transaction, confirmed_frontier, &sideband));
assert (sideband.height == confirmation_height_info.height + num_blocks_cemented);
debug_assert (ledger.store.block_get (transaction, confirmed_frontier, &sideband));
debug_assert (sideband.height == confirmation_height_info.height + num_blocks_cemented);
#endif
ledger.store.confirmation_height_put (transaction, account, nano::confirmation_height_info{ confirmation_height, confirmed_frontier });
ledger.cache.cemented_count += num_blocks_cemented;
@ -370,7 +370,7 @@ bool nano::confirmation_height_bounded::cement_blocks ()
{
new_cemented_frontier = pending.bottom_hash;
// If we are higher than the cemented frontier, we should be exactly 1 block above
assert (pending.bottom_height == confirmation_height_info.height + 1);
debug_assert (pending.bottom_height == confirmation_height_info.height + 1);
num_blocks_confirmed = pending.top_height - pending.bottom_height + 1;
start_height = pending.bottom_height;
}
@ -424,7 +424,7 @@ bool nano::confirmation_height_bounded::cement_blocks ()
else
{
// Confirm it is indeed the last one
assert (new_cemented_frontier == pending.top_hash);
debug_assert (new_cemented_frontier == pending.top_hash);
}
}
@ -445,8 +445,8 @@ bool nano::confirmation_height_bounded::cement_blocks ()
notify_observers_callback (cemented_blocks);
assert (pending_writes.empty ());
assert (pending_writes_size == 0);
debug_assert (pending_writes.empty ());
debug_assert (pending_writes_size == 0);
return false;
}

View file

@ -9,7 +9,6 @@
#include <boost/thread/latch.hpp>
#include <cassert>
#include <numeric>
nano::confirmation_height_processor::confirmation_height_processor (nano::ledger & ledger_a, nano::write_database_queue & write_database_queue_a, std::chrono::milliseconds batch_separate_pending_min_time_a, nano::logger_mt & logger_a, boost::latch & latch, confirmation_height_mode mode_a) :
@ -66,7 +65,7 @@ void nano::confirmation_height_processor::run (confirmation_height_mode mode_a)
// Don't want to mix up pending writes across different processors
if (mode_a == confirmation_height_mode::unbounded || (mode_a == confirmation_height_mode::automatic && blocks_within_automatic_unbounded_selection && confirmation_height_bounded_processor.pending_empty ()))
{
assert (confirmation_height_bounded_processor.pending_empty ());
debug_assert (confirmation_height_bounded_processor.pending_empty ());
if (confirmation_height_unbounded_processor.pending_empty ())
{
confirmation_height_unbounded_processor.prepare_new ();
@ -75,8 +74,8 @@ void nano::confirmation_height_processor::run (confirmation_height_mode mode_a)
}
else
{
assert (mode_a == confirmation_height_mode::bounded || mode_a == confirmation_height_mode::automatic);
assert (confirmation_height_unbounded_processor.pending_empty ());
debug_assert (mode_a == confirmation_height_mode::bounded || mode_a == confirmation_height_mode::automatic);
debug_assert (confirmation_height_unbounded_processor.pending_empty ());
if (confirmation_height_bounded_processor.pending_empty ())
{
confirmation_height_bounded_processor.prepare_new ();
@ -102,14 +101,14 @@ void nano::confirmation_height_processor::run (confirmation_height_mode mode_a)
// If there are blocks pending cementing, then make sure we flush out the remaining writes
if (!confirmation_height_bounded_processor.pending_empty ())
{
assert (confirmation_height_unbounded_processor.pending_empty ());
debug_assert (confirmation_height_unbounded_processor.pending_empty ());
auto scoped_write_guard = write_database_queue.wait (nano::writer::confirmation_height);
confirmation_height_bounded_processor.cement_blocks ();
lock_and_cleanup ();
}
else if (!confirmation_height_unbounded_processor.pending_empty ())
{
assert (confirmation_height_bounded_processor.pending_empty ());
debug_assert (confirmation_height_bounded_processor.pending_empty ());
auto scoped_write_guard = write_database_queue.wait (nano::writer::confirmation_height);
confirmation_height_unbounded_processor.cement_blocks ();
lock_and_cleanup ();
@ -147,7 +146,7 @@ void nano::confirmation_height_processor::add (nano::block_hash const & hash_a)
void nano::confirmation_height_processor::set_next_hash ()
{
nano::lock_guard<std::mutex> guard (mutex);
assert (!awaiting_processing.empty ());
debug_assert (!awaiting_processing.empty ());
original_hash = *awaiting_processing.begin ();
original_hashes_pending.insert (original_hash);
awaiting_processing.erase (original_hash);

View file

@ -172,7 +172,7 @@ void nano::confirmation_height_unbounded::collect_unconfirmed_receive_and_source
if (!hit_receive && !block_callback_data_a.empty ())
{
// Add the callbacks to the associated receive to retrieve later
assert (!receive_source_pairs_a.empty ());
debug_assert (!receive_source_pairs_a.empty ());
auto & last_receive_details = receive_source_pairs_a.back ().receive_details;
last_receive_details->source_block_callback_data.assign (block_callback_data_a.begin (), block_callback_data_a.end ());
block_callback_data_a.clear ();
@ -243,13 +243,13 @@ void nano::confirmation_height_unbounded::prepare_iterated_blocks_for_cementing
}
else
{
assert (receive_details);
debug_assert (receive_details);
if (preparation_data_a.already_traversed && receive_details->source_block_callback_data.empty ())
{
// We are confirming a block which has already been traversed and found no associated receive details for it.
auto & above_receive_details_w = implicit_receive_cemented_mapping[preparation_data_a.current];
assert (!above_receive_details_w.expired ());
debug_assert (!above_receive_details_w.expired ());
auto above_receive_details = above_receive_details_w.lock ();
auto num_blocks_already_confirmed = above_receive_details->num_blocks_confirmed - (above_receive_details->height - preparation_data_a.confirmation_height);
@ -289,7 +289,7 @@ void nano::confirmation_height_unbounded::prepare_iterated_blocks_for_cementing
// Get the difference and remove the callbacks
auto block_callbacks_to_remove = orig_num_blocks_confirmed - receive_details->num_blocks_confirmed;
receive_details->block_callback_data.erase (std::next (receive_details->block_callback_data.rbegin (), block_callbacks_to_remove).base (), receive_details->block_callback_data.end ());
assert (receive_details->block_callback_data.size () == receive_details->num_blocks_confirmed);
debug_assert (receive_details->block_callback_data.size () == receive_details->num_blocks_confirmed);
}
else
{
@ -324,8 +324,8 @@ bool nano::confirmation_height_unbounded::cement_blocks ()
nano::block_sideband sideband;
auto block = ledger.store.block_get (transaction, pending.hash, &sideband);
static nano::network_constants network_constants;
assert (network_constants.is_test_network () || block != nullptr);
assert (network_constants.is_test_network () || sideband.height == pending.height);
debug_assert (network_constants.is_test_network () || block != nullptr);
debug_assert (network_constants.is_test_network () || sideband.height == pending.height);
if (!block)
{
@ -337,7 +337,7 @@ bool nano::confirmation_height_unbounded::cement_blocks ()
#endif
ledger.stats.add (nano::stat::type::confirmation_height, nano::stat::detail::blocks_confirmed, nano::stat::dir::in, pending.height - confirmation_height);
ledger.stats.add (nano::stat::type::confirmation_height, nano::stat::detail::blocks_confirmed_unbounded, nano::stat::dir::in, pending.height - confirmation_height);
assert (pending.num_blocks_confirmed == pending.height - confirmation_height);
debug_assert (pending.num_blocks_confirmed == pending.height - confirmation_height);
confirmation_height = pending.height;
ledger.cache.cemented_count += pending.num_blocks_confirmed;
ledger.store.confirmation_height_put (transaction, pending.account, { confirmation_height, pending.hash });
@ -349,7 +349,7 @@ bool nano::confirmation_height_unbounded::cement_blocks ()
std::vector<nano::block_w_sideband> callback_data;
callback_data.reserve (pending.block_callback_data.size ());
std::transform (pending.block_callback_data.begin (), pending.block_callback_data.end (), std::back_inserter (callback_data), [& block_cache = block_cache](auto const & hash_a) {
assert (block_cache.find (hash_a) != block_cache.end ());
debug_assert (block_cache.find (hash_a) != block_cache.end ());
return block_cache.at (hash_a);
});
@ -359,8 +359,8 @@ bool nano::confirmation_height_unbounded::cement_blocks ()
total_pending_write_block_count -= pending.num_blocks_confirmed;
pending_writes.erase (pending_writes.begin ());
}
assert (total_pending_write_block_count == 0);
assert (pending_writes.empty ());
debug_assert (total_pending_write_block_count == 0);
debug_assert (pending_writes.empty ());
return false;
}

View file

@ -13,7 +13,7 @@ network (network_a)
void nano::confirmation_solicitor::prepare (std::vector<nano::representative> const & representatives_a)
{
assert (!prepared);
debug_assert (!prepared);
requests.clear ();
rebroadcasted = 0;
representatives = representatives_a;
@ -22,7 +22,7 @@ void nano::confirmation_solicitor::prepare (std::vector<nano::representative> co
bool nano::confirmation_solicitor::broadcast (nano::election const & election_a)
{
assert (prepared);
debug_assert (prepared);
bool result (true);
if (rebroadcasted++ < max_block_broadcasts)
{
@ -34,7 +34,7 @@ bool nano::confirmation_solicitor::broadcast (nano::election const & election_a)
bool nano::confirmation_solicitor::add (nano::election const & election_a)
{
assert (prepared);
debug_assert (prepared);
auto const max_channel_requests (max_confirm_req_batches * nano::network::confirm_req_hashes_max);
unsigned count = 0;
for (auto i (representatives.begin ()), n (representatives.end ()); i != n && count < max_election_requests; ++i)
@ -55,7 +55,7 @@ bool nano::confirmation_solicitor::add (nano::election const & election_a)
void nano::confirmation_solicitor::flush ()
{
assert (prepared);
debug_assert (prepared);
for (auto const & request_queue : requests)
{
auto const & channel (request_queue.first);

View file

@ -29,13 +29,13 @@ strand (node_a.io_ctx.get_executor ()),
need_resolve (request_a.peers),
elapsed (nano::timer_state::started, "distributed work generation timer")
{
assert (!finished);
assert (status == work_generation_status::ongoing);
debug_assert (!finished);
debug_assert (status == work_generation_status::ongoing);
}
nano::distributed_work::~distributed_work ()
{
assert (status != work_generation_status::ongoing);
debug_assert (status != work_generation_status::ongoing);
if (auto node_l = node_w.lock ())
{
if (!node_l->stopped && node_l->websocket_server && node_l->websocket_server->any_subscriber (nano::websocket::topic::work))

View file

@ -25,7 +25,7 @@ stopped (false)
void nano::election::confirm_once (nano::election_status_type type_a)
{
assert (!node.active.mutex.try_lock ());
debug_assert (!node.active.mutex.try_lock ());
if (!confirmed_m.exchange (true))
{
status.election_end = std::chrono::duration_cast<std::chrono::milliseconds> (std::chrono::system_clock::now ().time_since_epoch ());
@ -50,7 +50,7 @@ void nano::election::confirm_once (nano::election_status_type type_a)
void nano::election::stop ()
{
assert (!node.active.mutex.try_lock ());
debug_assert (!node.active.mutex.try_lock ());
if (!stopped && !confirmed ())
{
stopped = true;
@ -105,7 +105,7 @@ nano::tally_t nano::election::tally ()
void nano::election::confirm_if_quorum ()
{
auto tally_l (tally ());
assert (!tally_l.empty ());
debug_assert (!tally_l.empty ());
auto winner (tally_l.begin ());
auto block_l (winner->second);
status.tally = winner->first;
@ -243,7 +243,7 @@ size_t nano::election::last_votes_size ()
void nano::election::update_dependent ()
{
assert (!node.active.mutex.try_lock ());
debug_assert (!node.active.mutex.try_lock ());
std::vector<nano::block_hash> blocks_search;
auto hash (status.winner->hash ());
auto previous (status.winner->previous ());
@ -291,7 +291,7 @@ void nano::election::clear_blocks ()
auto erased (node.active.blocks.erase (hash));
(void)erased;
// clear_blocks () can be called in active_transactions::publish () before blocks insertion if election was confirmed
assert (erased == 1 || confirmed ());
debug_assert (erased == 1 || confirmed ());
node.active.erase_inactive_votes_cache (hash);
// Notify observers about dropped elections & blocks lost confirmed elections
if (stopped || hash != winner_hash)

View file

@ -114,7 +114,7 @@ nanoapi::BlockUnion nano::ipc::flatbuffers_builder::block_to_union (nano::block
}
default:
assert (false);
debug_assert (false);
}
return u;
}

View file

@ -22,7 +22,7 @@ std::shared_ptr<flatbuffers::Parser> nano::ipc::subscriber::get_parser (nano::ip
void nano::ipc::broker::start ()
{
node.observers.blocks.add ([this](nano::election_status const & status_a, nano::account const & account_a, nano::amount const & amount_a, bool is_state_send_a) {
assert (status_a.type != nano::election_status_type::ongoing);
debug_assert (status_a.type != nano::election_status_type::ongoing);
try
{
@ -46,7 +46,7 @@ void nano::ipc::broker::start ()
confirmation->confirmation_type = nanoapi::TopicConfirmationType::TopicConfirmationType_inactive;
break;
default:
assert (false);
debug_assert (false);
break;
};
confirmation->confirmation_type = nanoapi::TopicConfirmationType::TopicConfirmationType_active_quorum;
@ -119,7 +119,7 @@ void nano::ipc::broker::broadcast (std::shared_ptr<nanoapi::EventConfirmationT>
if (auto subscriber_l = itr->subscriber.lock ())
{
auto should_filter = [this, &itr, confirmation_a]() {
assert (itr->topic->options != nullptr);
debug_assert (itr->topic->options != nullptr);
auto conf_filter (itr->topic->options->confirmation_type_filter);
bool should_filter_conf_type_l (true);
@ -148,7 +148,7 @@ void nano::ipc::broker::broadcast (std::shared_ptr<nanoapi::EventConfirmationT>
auto decode_destination_ok_l (!destination_l.decode_account (state->link_as_account));
(void)decode_source_ok_l;
(void)decode_destination_ok_l;
assert (decode_source_ok_l && decode_destination_ok_l);
debug_assert (decode_source_ok_l && decode_destination_ok_l);
if (this->node.wallets.exists (transaction_l, source_l) || this->node.wallets.exists (transaction_l, destination_l))
{
should_filter_account_l = false;

View file

@ -2059,7 +2059,7 @@ void epoch_upgrader (std::shared_ptr<nano::node> node_a, nano::private_key const
nano::raw_key raw_key;
raw_key.data = prv_a;
auto signer (nano::pub_key (prv_a));
assert (signer == node_a->ledger.epoch_signer (link));
debug_assert (signer == node_a->ledger.epoch_signer (link));
class account_upgrade_item final
{
@ -3978,7 +3978,7 @@ void nano::json_handler::telemetry ()
if (!ec)
{
assert (channel);
debug_assert (channel);
node.telemetry.get_metrics_single_peer_async (channel, [rpc_l](auto const & single_telemetry_metric_a) {
if (!single_telemetry_metric_a.error)
{
@ -4428,7 +4428,7 @@ void nano::json_handler::wallet_change_seed ()
rpc_l->response_l.put ("success", "");
rpc_l->response_l.put ("last_restored_account", account.to_account ());
auto index (wallet->store.deterministic_index_get (transaction));
assert (index > 0);
debug_assert (index > 0);
rpc_l->response_l.put ("restored_count", std::to_string (index));
}
else
@ -4487,7 +4487,7 @@ void nano::json_handler::wallet_create ()
nano::public_key account (wallet->change_seed (transaction, seed));
rpc_l->response_l.put ("last_restored_account", account.to_account ());
auto index (wallet->store.deterministic_index_get (transaction));
assert (index > 0);
debug_assert (index > 0);
rpc_l->response_l.put ("restored_count", std::to_string (index));
}
}

View file

@ -310,7 +310,7 @@ void nano::mdb_store::upgrade_v2_to_v3 (nano::write_transaction const & transact
nano::account_info_v5 info ((*i)->second);
representative_visitor visitor (transaction_a, *this);
visitor.compute (info.head);
assert (!visitor.result.is_zero ());
debug_assert (!visitor.result.is_zero ());
info.rep_block = visitor.result;
auto impl (boost::polymorphic_downcast<nano::mdb_iterator<nano::account, nano::account_info_v5> *> (i.get ()));
mdb_cursor_put (impl->cursor, nano::mdb_val (account_l), nano::mdb_val (sizeof (info), &info), MDB_CURRENT);
@ -331,7 +331,7 @@ void nano::mdb_store::upgrade_v3_to_v4 (nano::write_transaction const & transact
while (!items.empty ())
{
auto status (mdb_put (env.tx (transaction_a), pending, nano::mdb_val (items.front ().first), nano::mdb_val (items.front ().second), 0));
assert (success (status));
debug_assert (success (status));
items.pop ();
}
}
@ -360,7 +360,7 @@ void nano::mdb_store::upgrade_v4_to_v5 (nano::write_transaction const & transact
{
nano::block_type type;
auto value (block_raw_get (transaction_a, block->previous (), type));
assert (value.size () != 0);
debug_assert (value.size () != 0);
std::vector<uint8_t> data (static_cast<uint8_t *> (value.data ()), static_cast<uint8_t *> (value.data ()) + value.size ());
std::copy (hash.bytes.begin (), hash.bytes.end (), data.end () - nano::block_sideband::size (type));
block_raw_put (transaction_a, data, type, block->previous ());
@ -386,7 +386,7 @@ void nano::mdb_store::upgrade_v5_to_v6 (nano::write_transaction const & transact
{
++block_count;
auto block (block_get (transaction_a, hash));
assert (block != nullptr);
debug_assert (block != nullptr);
hash = block->previous ();
}
headers.emplace_back (account, nano::account_info_v13{ info_old.head, info_old.rep_block, info_old.open_block, info_old.balance, info_old.modified, block_count, nano::epoch::epoch_0 });
@ -434,7 +434,7 @@ void nano::mdb_store::upgrade_v8_to_v9 (nano::write_transaction const & transact
}
auto status1 (mdb_put (env.tx (transaction_a), vote, nano::mdb_val (i->first), nano::mdb_val (vector.size (), vector.data ()), 0));
release_assert (status1 == 0);
assert (!error);
debug_assert (!error);
}
mdb_drop (env.tx (transaction_a), sequence, 1);
}
@ -494,7 +494,7 @@ void nano::mdb_store::upgrade_v12_to_v13 (nano::write_transaction & transaction_
bool is_state_block_v1 = false;
auto block = block_get_v14 (transaction_a, hash, &sideband, &is_state_block_v1);
assert (block != nullptr);
debug_assert (block != nullptr);
if (sideband.height == 0)
{
sideband.height = height;
@ -514,7 +514,7 @@ void nano::mdb_store::upgrade_v12_to_v13 (nano::write_transaction & transaction_
nano::block_predecessor_set<MDB_val, nano::mdb_store> predecessor (transaction_a, *this);
block->visit (predecessor);
assert (block->previous ().is_zero () || block_successor (transaction_a, block->previous ()) == hash);
debug_assert (block->previous ().is_zero () || block_successor (transaction_a, block->previous ()) == hash);
cost += 16;
}
else
@ -598,7 +598,7 @@ void nano::mdb_store::upgrade_v14_to_v15 (nano::write_transaction & transaction_
logger.always_log ("Finished extracting confirmation height to its own database");
assert (account_counters.are_equal ());
debug_assert (account_counters.are_equal ());
// No longer need accounts_v1, keep v0 but clear it
mdb_drop (env.tx (transaction_a), accounts_v1, 1);
mdb_drop (env.tx (transaction_a), accounts_v0, 0);
@ -651,7 +651,7 @@ void nano::mdb_store::upgrade_v14_to_v15 (nano::write_transaction & transaction_
i_state.from_first_database ? ++state_counters.after_v0 : ++state_counters.after_v1;
}
assert (state_counters.are_equal ());
debug_assert (state_counters.are_equal ());
logger.always_log ("Epoch merge upgrade: Finished state blocks, now doing pending blocks");
state_blocks = state_blocks_new;
@ -675,7 +675,7 @@ void nano::mdb_store::upgrade_v14_to_v15 (nano::write_transaction & transaction_
i_pending.from_first_database ? ++pending_counters.after_v0 : ++pending_counters.after_v1;
}
assert (pending_counters.are_equal ());
debug_assert (pending_counters.are_equal ());
// No longer need the pending v1 table
mdb_drop (env.tx (transaction_a), pending_v1, 1);
@ -693,7 +693,7 @@ void nano::mdb_store::upgrade_v14_to_v15 (nano::write_transaction & transaction_
void nano::mdb_store::upgrade_v15_to_v16 (nano::write_transaction const & transaction_a)
{
// Representation table is no longer used
assert (representation != 0);
debug_assert (representation != 0);
if (representation != 0)
{
auto status (mdb_drop (env.tx (transaction_a), representation, 1));
@ -719,7 +719,7 @@ void nano::mdb_store::upgrade_v16_to_v17 (nano::write_transaction const & transa
uint64_t confirmation_height (i->second);
// Check account hashes matches both the accounts table and confirmation height table
assert (account == account_info_i->first);
debug_assert (account == account_info_i->first);
auto const & account_info = account_info_i->second;
@ -734,17 +734,17 @@ void nano::mdb_store::upgrade_v16_to_v17 (nano::write_transaction const & transa
// The confirmation height of the account is closer to the bottom of the chain, so start there and work up
nano::block_sideband sideband;
auto block = block_get (transaction_a, account_info.open_block, &sideband);
assert (block);
debug_assert (block);
auto height = 1;
while (height != confirmation_height)
{
block = block_get (transaction_a, sideband.successor, &sideband);
assert (block);
debug_assert (block);
++height;
}
assert (sideband.height == confirmation_height);
debug_assert (sideband.height == confirmation_height);
confirmation_height_infos.emplace_back (account, confirmation_height_info{ confirmation_height, block->hash () });
}
else
@ -756,7 +756,7 @@ void nano::mdb_store::upgrade_v16_to_v17 (nano::write_transaction const & transa
while (height != confirmation_height)
{
block = block_get (transaction_a, block->previous ());
assert (block);
debug_assert (block);
--height;
}
confirmation_height_infos.emplace_back (account, confirmation_height_info{ confirmation_height, block->hash () });
@ -899,7 +899,7 @@ void nano::mdb_store::version_put (nano::write_transaction const & transaction_a
bool nano::mdb_store::block_info_get (nano::transaction const & transaction_a, nano::block_hash const & hash_a, nano::block_info & block_info_a) const
{
assert (!full_sideband (transaction_a));
debug_assert (!full_sideband (transaction_a));
nano::mdb_val value;
auto status (mdb_get (env.tx (transaction_a), blocks_info, nano::mdb_val (hash_a), value));
release_assert (status == 0 || status == MDB_NOTFOUND);
@ -907,14 +907,14 @@ bool nano::mdb_store::block_info_get (nano::transaction const & transaction_a, n
if (status != MDB_NOTFOUND)
{
result = false;
assert (value.size () == sizeof (block_info_a.account.bytes) + sizeof (block_info_a.balance.bytes));
debug_assert (value.size () == sizeof (block_info_a.account.bytes) + sizeof (block_info_a.balance.bytes));
nano::bufferstream stream (reinterpret_cast<uint8_t const *> (value.data ()), value.size ());
auto error1 (nano::try_read (stream, block_info_a.account));
(void)error1;
assert (!error1);
debug_assert (!error1);
auto error2 (nano::try_read (stream, block_info_a.balance));
(void)error2;
assert (!error2);
debug_assert (!error2);
}
return result;
}
@ -1096,7 +1096,7 @@ size_t nano::mdb_store::block_successor_offset_v14 (nano::transaction const & tr
else
{
// Read old successor-only sideband
assert (entry_size_a == nano::block::size (type_a) + sizeof (nano::uint256_union));
debug_assert (entry_size_a == nano::block::size (type_a) + sizeof (nano::uint256_union));
result = entry_size_a - sizeof (nano::uint256_union);
}
return result;
@ -1109,11 +1109,11 @@ nano::block_hash nano::mdb_store::block_successor_v14 (nano::transaction const &
nano::block_hash result;
if (value.size () != 0)
{
assert (value.size () >= result.bytes.size ());
debug_assert (value.size () >= result.bytes.size ());
nano::bufferstream stream (reinterpret_cast<uint8_t const *> (value.data ()) + block_successor_offset_v14 (transaction_a, value.size (), type), result.bytes.size ());
auto error (nano::try_read (stream, result.bytes));
(void)error;
assert (!error);
debug_assert (!error);
}
else
{
@ -1206,20 +1206,20 @@ nano::account nano::mdb_store::block_account_v14 (nano::transaction const & tran
{
result = sideband.account;
}
assert (!result.is_zero ());
debug_assert (!result.is_zero ());
return result;
}
// Return account containing hash
nano::account nano::mdb_store::block_account_computed_v14 (nano::transaction const & transaction_a, nano::block_hash const & hash_a) const
{
assert (!full_sideband (transaction_a));
debug_assert (!full_sideband (transaction_a));
nano::account result (0);
auto hash (hash_a);
while (result.is_zero ())
{
auto block (block_get_v14 (transaction_a, hash));
assert (block);
debug_assert (block);
result = block->account ();
if (result.is_zero ())
{
@ -1242,20 +1242,20 @@ nano::account nano::mdb_store::block_account_computed_v14 (nano::transaction con
if (result.is_zero ())
{
auto successor (block_successor_v14 (transaction_a, hash));
assert (!successor.is_zero ());
debug_assert (!successor.is_zero ());
hash = successor;
}
}
}
}
}
assert (!result.is_zero ());
debug_assert (!result.is_zero ());
return result;
}
nano::uint128_t nano::mdb_store::block_balance_computed_v14 (nano::transaction const & transaction_a, nano::block_hash const & hash_a) const
{
assert (!full_sideband (transaction_a));
debug_assert (!full_sideband (transaction_a));
summation_visitor visitor (transaction_a, *this, true);
return visitor.compute_balance (hash_a);
}
@ -1269,7 +1269,7 @@ std::shared_ptr<nano::block> nano::mdb_store::block_get_v14 (nano::transaction c
{
nano::bufferstream stream (reinterpret_cast<uint8_t const *> (value.data ()), value.size ());
result = nano::deserialize_block (stream, type);
assert (result != nullptr);
debug_assert (result != nullptr);
if (sideband_a)
{
sideband_a->type = type;
@ -1277,7 +1277,7 @@ std::shared_ptr<nano::block> nano::mdb_store::block_get_v14 (nano::transaction c
{
bool error = sideband_a->deserialize (stream);
(void)error;
assert (!error);
debug_assert (!error);
}
else
{

View file

@ -74,7 +74,7 @@ public:
nano::store_iterator_impl<T, U> & operator++ () override
{
assert (cursor != nullptr);
debug_assert (cursor != nullptr);
auto status (mdb_cursor_get (cursor, &current.first.value, &current.second.value, MDB_NEXT));
release_assert (status == 0 || status == MDB_NOTFOUND);
if (status == MDB_NOTFOUND)
@ -97,9 +97,9 @@ public:
{
auto const other_a (boost::polymorphic_downcast<nano::mdb_iterator<T, U> const *> (&base_a));
auto result (current.first.data () == other_a->current.first.data ());
assert (!result || (current.first.size () == other_a->current.first.size ()));
assert (!result || (current.second.data () == other_a->current.second.data ()));
assert (!result || (current.second.size () == other_a->current.second.size ()));
debug_assert (!result || (current.first.size () == other_a->current.first.size ()));
debug_assert (!result || (current.second.data () == other_a->current.second.data ()));
debug_assert (!result || (current.second.size () == other_a->current.second.size ()));
return result;
}
@ -130,7 +130,7 @@ public:
{
current.first = nano::db_val<MDB_val> ();
current.second = nano::db_val<MDB_val> ();
assert (is_end_sentinal ());
debug_assert (is_end_sentinal ());
}
nano::mdb_iterator<T, U> & operator= (nano::mdb_iterator<T, U> && other_a)
@ -203,7 +203,7 @@ public:
bool operator== (nano::store_iterator_impl<T, U> const & base_a) const override
{
assert ((dynamic_cast<nano::mdb_merge_iterator<T, U> const *> (&base_a) != nullptr) && "Incompatible iterator comparison");
debug_assert ((dynamic_cast<nano::mdb_merge_iterator<T, U> const *> (&base_a) != nullptr) && "Incompatible iterator comparison");
auto & other (static_cast<nano::mdb_merge_iterator<T, U> const &> (base_a));
return *impl1 == *other.impl1 && *impl2 == *other.impl2;
}

View file

@ -147,7 +147,7 @@ void nano::mdb_txn_tracker::serialize_json (boost::property_tree::ptree & json,
std::transform (copy_stats.cbegin (), copy_stats.cend (), std::back_inserter (times_since_start), [](const auto & stat) {
return stat.timer.since_start ();
});
assert (times_since_start.size () == copy_stats.size ());
debug_assert (times_since_start.size () == copy_stats.size ());
for (size_t i = 0; i < times_since_start.size (); ++i)
{
@ -197,7 +197,7 @@ void nano::mdb_txn_tracker::output_finished (nano::mdb_txn_stats const & mdb_txn
if (!should_ignore && ((is_write && time_open >= txn_tracking_config.min_write_txn_time) || (!is_write && time_open >= txn_tracking_config.min_read_txn_time)))
{
assert (mdb_txn_stats.stacktrace);
debug_assert (mdb_txn_stats.stacktrace);
logger.always_log (boost::str (boost::format ("%1%ms %2% held on thread %3%\n%4%") % mdb_txn_stats.timer.since_start ().count () % (is_write ? "write lock" : "read") % mdb_txn_stats.thread_name % *mdb_txn_stats.stacktrace));
}
}
@ -205,7 +205,7 @@ void nano::mdb_txn_tracker::output_finished (nano::mdb_txn_stats const & mdb_txn
void nano::mdb_txn_tracker::add (const nano::transaction_impl * transaction_impl)
{
nano::lock_guard<std::mutex> guard (mutex);
assert (std::find_if (stats.cbegin (), stats.cend (), matches_txn (transaction_impl)) == stats.cend ());
debug_assert (std::find_if (stats.cbegin (), stats.cend (), matches_txn (transaction_impl)) == stats.cend ());
stats.emplace_back (transaction_impl);
}

View file

@ -2,7 +2,7 @@
nano::wallet_value::wallet_value (nano::db_val<MDB_val> const & val_a)
{
assert (val_a.size () == sizeof (*this));
debug_assert (val_a.size () == sizeof (*this));
std::copy (reinterpret_cast<uint8_t const *> (val_a.data ()), reinterpret_cast<uint8_t const *> (val_a.data ()) + sizeof (key), key.chars.begin ());
std::copy (reinterpret_cast<uint8_t const *> (val_a.data ()) + sizeof (key), reinterpret_cast<uint8_t const *> (val_a.data ()) + sizeof (key) + sizeof (work), reinterpret_cast<char *> (&work));
}

View file

@ -95,7 +95,7 @@ void nano::logging::init (boost::filesystem::path const & application_path_a)
boost::log::keywords::max_size = max_size, // max total size in bytes of all log files
boost::log::keywords::format = format_with_timestamp);
#else
assert (false);
debug_assert (false);
#endif
}
else

View file

@ -70,7 +70,7 @@ void nano::network::start ()
if (!node.flags.disable_udp)
{
udp_channels.start ();
assert (udp_channels.get_local_endpoint ().port () == port);
debug_assert (udp_channels.get_local_endpoint ().port () == port);
}
if (!node.flags.disable_tcp_realtime)
{
@ -136,7 +136,7 @@ void nano::network::send_node_id_handshake (std::shared_ptr<nano::transport::cha
if (respond_to)
{
response = std::make_pair (node.node_id.pub, nano::sign_message (node.node_id.prv, node.node_id.pub, *respond_to));
assert (!nano::validate_message (response->first, *respond_to, response->second));
debug_assert (!nano::validate_message (response->first, *respond_to, response->second));
}
nano::node_id_handshake message (query, response);
if (node.config.logging.network_node_id_handshake_logging ())
@ -427,19 +427,19 @@ public:
}
void bulk_pull (nano::bulk_pull const &) override
{
assert (false);
debug_assert (false);
}
void bulk_pull_account (nano::bulk_pull_account const &) override
{
assert (false);
debug_assert (false);
}
void bulk_push (nano::bulk_push const &) override
{
assert (false);
debug_assert (false);
}
void frontier_req (nano::frontier_req const &) override
{
assert (false);
debug_assert (false);
}
void node_id_handshake (nano::node_id_handshake const & message_a) override
{
@ -590,15 +590,15 @@ std::unordered_set<std::shared_ptr<nano::transport::channel>> nano::network::ran
void nano::network::random_fill (std::array<nano::endpoint, 8> & target_a) const
{
auto peers (random_set (target_a.size (), 0, false)); // Don't include channels with ephemeral remote ports
assert (peers.size () <= target_a.size ());
debug_assert (peers.size () <= target_a.size ());
auto endpoint (nano::endpoint (boost::asio::ip::address_v6{}, 0));
assert (endpoint.address ().is_v6 ());
debug_assert (endpoint.address ().is_v6 ());
std::fill (target_a.begin (), target_a.end (), endpoint);
auto j (target_a.begin ());
for (auto i (peers.begin ()), n (peers.end ()); i != n; ++i, ++j)
{
assert ((*i)->get_endpoint ().address ().is_v6 ());
assert (j < target_a.end ());
debug_assert ((*i)->get_endpoint ().address ().is_v6 ());
debug_assert (j < target_a.end ());
*j = (*i)->get_endpoint ();
}
}
@ -713,8 +713,8 @@ slab (size * count),
entries (count),
stopped (false)
{
assert (count > 0);
assert (size > 0);
debug_assert (count > 0);
debug_assert (size > 0);
auto slab_data (slab.data ());
auto entry_data (entries.data ());
for (auto i (0); i < count; ++i, ++entry_data)
@ -750,7 +750,7 @@ nano::message_buffer * nano::message_buffer_manager::allocate ()
void nano::message_buffer_manager::enqueue (nano::message_buffer * data_a)
{
assert (data_a != nullptr);
debug_assert (data_a != nullptr);
{
nano::lock_guard<std::mutex> lock (mutex);
full.push_back (data_a);
@ -776,7 +776,7 @@ nano::message_buffer * nano::message_buffer_manager::dequeue ()
void nano::message_buffer_manager::release (nano::message_buffer * data_a)
{
assert (data_a != nullptr);
debug_assert (data_a != nullptr);
{
nano::lock_guard<std::mutex> lock (mutex);
free.push_back (data_a);
@ -796,7 +796,7 @@ void nano::message_buffer_manager::stop ()
boost::optional<nano::uint256_union> nano::syn_cookies::assign (nano::endpoint const & endpoint_a)
{
auto ip_addr (endpoint_a.address ());
assert (ip_addr.is_v6 ());
debug_assert (ip_addr.is_v6 ());
nano::lock_guard<std::mutex> lock (syn_cookie_mutex);
unsigned & ip_cookies = cookies_per_ip[ip_addr];
boost::optional<nano::uint256_union> result;
@ -818,7 +818,7 @@ boost::optional<nano::uint256_union> nano::syn_cookies::assign (nano::endpoint c
bool nano::syn_cookies::validate (nano::endpoint const & endpoint_a, nano::account const & node_id, nano::signature const & sig)
{
auto ip_addr (endpoint_a.address ());
assert (ip_addr.is_v6 ());
debug_assert (ip_addr.is_v6 ());
nano::lock_guard<std::mutex> lock (syn_cookie_mutex);
auto result (true);
auto cookie_it (cookies.find (endpoint_a));
@ -833,7 +833,7 @@ bool nano::syn_cookies::validate (nano::endpoint const & endpoint_a, nano::accou
}
else
{
assert (false && "More SYN cookies deleted than created for IP");
debug_assert (false && "More SYN cookies deleted than created for IP");
}
}
return result;
@ -855,7 +855,7 @@ void nano::syn_cookies::purge (std::chrono::steady_clock::time_point const & cut
}
else
{
assert (false && "More SYN cookies deleted than created for IP");
debug_assert (false && "More SYN cookies deleted than created for IP");
}
it = cookies.erase (it);
}

View file

@ -164,7 +164,7 @@ startup_time (std::chrono::steady_clock::now ())
observers.wallet.notify (active);
};
network.channel_observer = [this](std::shared_ptr<nano::transport::channel> channel_a) {
assert (channel_a != nullptr);
debug_assert (channel_a != nullptr);
observers.endpoint.notify (channel_a);
};
network.disconnect_observer = [this]() {
@ -235,7 +235,7 @@ startup_time (std::chrono::steady_clock::now ())
if (websocket_server)
{
observers.blocks.add ([this](nano::election_status const & status_a, nano::account const & account_a, nano::amount const & amount_a, bool is_state_send_a) {
assert (status_a.type != nano::election_status_type::ongoing);
debug_assert (status_a.type != nano::election_status_type::ongoing);
if (this->websocket_server->any_subscriber (nano::websocket::topic::confirmation))
{
@ -284,7 +284,7 @@ startup_time (std::chrono::steady_clock::now ())
}
// Add block confirmation type stats regardless of http-callback and websocket subscriptions
observers.blocks.add ([this](nano::election_status const & status_a, nano::account const & account_a, nano::amount const & amount_a, bool is_state_send_a) {
assert (status_a.type != nano::election_status_type::ongoing);
debug_assert (status_a.type != nano::election_status_type::ongoing);
switch (status_a.type)
{
case nano::election_status_type::active_confirmed_quorum:
@ -790,7 +790,7 @@ void nano::node::long_inactivity_cleanup ()
{
++sample;
}
assert (sample != n);
debug_assert (sample != n);
auto const one_week_ago = (std::chrono::system_clock::now () - std::chrono::hours (7 * 24)).time_since_epoch ().count ();
perform_cleanup = sample->first < one_week_ago;
}
@ -957,7 +957,7 @@ void nano::node::unchecked_cleanup ()
cleaning_list.pop_front ();
if (!store.unchecked_del (transaction, key))
{
assert (ledger.cache.unchecked_count > 0);
debug_assert (ledger.cache.unchecked_count > 0);
--ledger.cache.unchecked_count;
}
}
@ -977,7 +977,7 @@ void nano::node::ongoing_unchecked_cleanup ()
int nano::node::price (nano::uint128_t const & balance_a, int amount_a)
{
assert (balance_a >= amount_a * nano::Gxrb_ratio);
debug_assert (balance_a >= amount_a * nano::Gxrb_ratio);
auto balance_l (balance_a);
double result (0.0);
for (auto i (0); i < amount_a; ++i)
@ -1054,25 +1054,25 @@ boost::optional<uint64_t> nano::node::work_generate_blocking (nano::work_version
boost::optional<uint64_t> nano::node::work_generate_blocking (nano::block & block_a)
{
assert (network_params.network.is_test_network ());
debug_assert (network_params.network.is_test_network ());
return work_generate_blocking (block_a, network_params.network.publish_threshold);
}
boost::optional<uint64_t> nano::node::work_generate_blocking (nano::block & block_a, uint64_t difficulty_a)
{
assert (network_params.network.is_test_network ());
debug_assert (network_params.network.is_test_network ());
return work_generate_blocking (nano::work_version::work_1, block_a, difficulty_a);
}
boost::optional<uint64_t> nano::node::work_generate_blocking (nano::root const & root_a)
{
assert (network_params.network.is_test_network ());
debug_assert (network_params.network.is_test_network ());
return work_generate_blocking (root_a, network_params.network.publish_threshold);
}
boost::optional<uint64_t> nano::node::work_generate_blocking (nano::root const & root_a, uint64_t difficulty_a)
{
assert (network_params.network.is_test_network ());
debug_assert (network_params.network.is_test_network ());
return work_generate_blocking (nano::work_version::work_1, root_a, difficulty_a);
}
@ -1181,7 +1181,7 @@ public:
if (!node.store.block_exists (transaction, hash))
{
node.logger.try_log (boost::str (boost::format ("Confirmed block is missing: %1%") % hash.to_string ()));
assert (false && "Confirmed block is missing");
debug_assert (false && "Confirmed block is missing");
}
else
{

View file

@ -60,7 +60,7 @@ external_address (boost::asio::ip::address_v6{}.to_string ())
preconfigured_representatives.emplace_back ("3FE80B4BC842E82C1C18ABFEEC47EA989E63953BC82AC411F304D13833D52A56");
break;
default:
assert (false);
debug_assert (false);
break;
}
}
@ -857,7 +857,7 @@ void nano::node_config::deserialize_address (std::string const & entry_a, std::v
nano::account nano::node_config::random_representative () const
{
assert (!preconfigured_representatives.empty ());
debug_assert (!preconfigured_representatives.empty ());
size_t index (nano::random_pool::generate_word32 (0, static_cast<CryptoPP::word32> (preconfigured_representatives.size () - 1)));
auto result (preconfigured_representatives[index]);
return result;

View file

@ -3,8 +3,6 @@
#include <nano/secure/common.hpp>
#include <nano/secure/ledger.hpp>
#include <cassert>
nano::online_reps::online_reps (nano::ledger & ledger_a, nano::network_params & network_params_a, nano::uint128_t minimum_a) :
ledger (ledger_a),
network_params (network_params_a),
@ -33,7 +31,7 @@ void nano::online_reps::sample ()
while (ledger.store.online_weight_count (transaction) >= network_params.node.max_weight_samples)
{
auto oldest (ledger.store.online_weight_begin (transaction));
assert (oldest != ledger.store.online_weight_end ());
debug_assert (oldest != ledger.store.online_weight_end ());
ledger.store.online_weight_del (transaction, oldest->first);
}
// Calculate current active rep weight

View file

@ -28,13 +28,13 @@ void nano::payment_observer_processor::observer_action (nano::account const & ac
void nano::payment_observer_processor::add (nano::account const & account_a, std::shared_ptr<nano::json_payment_observer> payment_observer_a)
{
nano::lock_guard<std::mutex> lock (mutex);
assert (payment_observers.find (account_a) == payment_observers.end ());
debug_assert (payment_observers.find (account_a) == payment_observers.end ());
payment_observers[account_a] = payment_observer_a;
}
void nano::payment_observer_processor::erase (nano::account & account_a)
{
nano::lock_guard<std::mutex> lock (mutex);
assert (payment_observers.find (account_a) != payment_observers.end ());
debug_assert (payment_observers.find (account_a) != payment_observers.end ());
payment_observers.erase (account_a);
}

View file

@ -44,7 +44,7 @@ void nano::rep_crawler::validate ()
{
auto & vote = i.second;
auto & channel = i.first;
assert (channel != nullptr);
debug_assert (channel != nullptr);
nano::uint128_t rep_weight = node.ledger.weight (vote->account);
if (rep_weight > minimum)
{
@ -59,7 +59,7 @@ void nano::rep_crawler::validate ()
// Update if representative channel was changed
if (info.channel->get_endpoint () != channel->get_endpoint ())
{
assert (info.account == vote->account);
debug_assert (info.account == vote->account);
updated_or_inserted = true;
info.weight = rep_weight;
info.channel = channel;
@ -166,7 +166,7 @@ void nano::rep_crawler::query (std::vector<std::shared_ptr<nano::transport::chan
}
for (auto i (channels_a.begin ()), n (channels_a.end ()); i != n; ++i)
{
assert (*i != nullptr);
debug_assert (*i != nullptr);
on_rep_request (*i);
node.network.send_confirm_req (*i, block);
}

View file

@ -31,7 +31,7 @@ public:
representative (nano::account account_a, nano::amount weight_a, std::shared_ptr<nano::transport::channel> channel_a) :
account (account_a), weight (weight_a), channel (channel_a)
{
assert (channel != nullptr);
debug_assert (channel != nullptr);
}
std::reference_wrapper<nano::transport::channel const> channel_ref () const
{

View file

@ -26,7 +26,7 @@ thread ([this]() { run (); })
void nano::request_aggregator::add (std::shared_ptr<nano::transport::channel> & channel_a, std::vector<std::pair<nano::block_hash, nano::root>> const & hashes_roots_a)
{
assert (wallets.rep_counts ().voting > 0);
debug_assert (wallets.rep_counts ().voting > 0);
bool error = true;
auto const endpoint (nano::transport::map_endpoint_to_v6 (channel_a->get_endpoint ()));
nano::unique_lock<std::mutex> lock (mutex);
@ -192,7 +192,7 @@ std::vector<nano::block_hash> nano::request_aggregator::aggregate (nano::transac
to_generate.push_back (successor);
}
auto successor_block (store.block_get (transaction_a, successor));
assert (successor_block != nullptr);
debug_assert (successor_block != nullptr);
nano::publish publish (successor_block);
pool_a.channel->send (publish);
}

View file

@ -127,7 +127,7 @@ nano::write_transaction nano::rocksdb_store::tx_begin_write (std::vector<nano::t
}
// Tables must be kept in alphabetical order. These can be used for mutex locking, so order is important to prevent deadlocking
assert (std::is_sorted (tables_requiring_locks_a.begin (), tables_requiring_locks_a.end ()));
debug_assert (std::is_sorted (tables_requiring_locks_a.begin (), tables_requiring_locks_a.end ()));
return nano::write_transaction{ std::move (txn) };
}
@ -149,7 +149,7 @@ rocksdb::ColumnFamilyHandle * nano::rocksdb_store::table_to_column_family (table
auto iter = std::find_if (handles_l.begin (), handles_l.end (), [name](auto handle) {
return (handle->GetName () == name);
});
assert (iter != handles_l.end ());
debug_assert (iter != handles_l.end ());
return *iter;
};
@ -172,7 +172,7 @@ rocksdb::ColumnFamilyHandle * nano::rocksdb_store::table_to_column_family (table
case tables::pending:
return get_handle ("pending");
case tables::blocks_info:
assert (false);
debug_assert (false);
case tables::representation:
return get_handle ("representation");
case tables::unchecked:
@ -214,9 +214,9 @@ bool nano::rocksdb_store::exists (nano::transaction const & transaction_a, table
int nano::rocksdb_store::del (nano::write_transaction const & transaction_a, tables table_a, nano::rocksdb_val const & key_a)
{
assert (transaction_a.contains (table_a));
debug_assert (transaction_a.contains (table_a));
// RocksDB errors when trying to delete an entry which doesn't exist. It is a pre-condition that the key exists
assert (exists (transaction_a, table_a, key_a));
debug_assert (exists (transaction_a, table_a, key_a));
// Removing an entry so counts may need adjusting
if (is_caching_counts (table_a))
@ -230,13 +230,13 @@ int nano::rocksdb_store::del (nano::write_transaction const & transaction_a, tab
bool nano::rocksdb_store::block_info_get (nano::transaction const &, nano::block_hash const &, nano::block_info &) const
{
// Should not be called as the RocksDB backend does not use this table
assert (false);
debug_assert (false);
return true;
}
void nano::rocksdb_store::version_put (nano::write_transaction const & transaction_a, int version_a)
{
assert (transaction_a.contains (tables::meta));
debug_assert (transaction_a.contains (tables::meta));
nano::uint256_union version_key (1);
nano::uint256_union version_value (version_a);
auto status (put (transaction_a, tables::meta, version_key, nano::rocksdb_val (version_value)));
@ -245,7 +245,7 @@ void nano::rocksdb_store::version_put (nano::write_transaction const & transacti
rocksdb::Transaction * nano::rocksdb_store::tx (nano::transaction const & transaction_a) const
{
assert (!is_read (transaction_a));
debug_assert (!is_read (transaction_a));
return static_cast<rocksdb::Transaction *> (transaction_a.get_handle ());
}
@ -318,7 +318,7 @@ int nano::rocksdb_store::decrement (nano::write_transaction const & transaction_
int nano::rocksdb_store::put (nano::write_transaction const & transaction_a, tables table_a, nano::rocksdb_val const & key_a, nano::rocksdb_val const & value_a)
{
assert (transaction_a.contains (table_a));
debug_assert (transaction_a.contains (table_a));
auto txn = tx (transaction_a);
if (is_caching_counts (table_a))
@ -398,7 +398,7 @@ size_t nano::rocksdb_store::count (nano::transaction const & transaction_a, tabl
int nano::rocksdb_store::drop (nano::write_transaction const & transaction_a, tables table_a)
{
assert (transaction_a.contains (table_a));
debug_assert (transaction_a.contains (table_a));
auto col = table_to_column_family (table_a);
int status = static_cast<int> (rocksdb::Status::Code::kOk);
@ -439,7 +439,7 @@ int nano::rocksdb_store::clear (rocksdb::ColumnFamilyHandle * column_family)
// Need to add it back as we just want to clear the contents
auto handle_it = std::find (handles.begin (), handles.end (), column_family);
assert (handle_it != handles.cend ());
debug_assert (handle_it != handles.cend ());
status = db->CreateColumnFamily (get_cf_options (), name, &column_family);
release_assert (status.ok ());
*handle_it = column_family;

View file

@ -18,7 +18,7 @@ inline bool is_read (nano::transaction const & transaction_a)
inline rocksdb::ReadOptions const & snapshot_options (nano::transaction const & transaction_a)
{
assert (is_read (transaction_a));
debug_assert (is_read (transaction_a));
return *static_cast<const rocksdb::ReadOptions *> (transaction_a.get_handle ());
}
}
@ -136,9 +136,9 @@ public:
}
auto result (std::memcmp (current.first.data (), other_a->current.first.data (), current.first.size ()) == 0);
assert (!result || (current.first.size () == other_a->current.first.size ()));
assert (!result || (current.second.data () == other_a->current.second.data ()));
assert (!result || (current.second.size () == other_a->current.second.size ()));
debug_assert (!result || (current.first.size () == other_a->current.first.size ()));
debug_assert (!result || (current.second.data () == other_a->current.second.data ()));
debug_assert (!result || (current.second.size () == other_a->current.second.size ()));
return result;
}
@ -172,7 +172,7 @@ public:
{
current.first = nano::rocksdb_val{};
current.second = nano::rocksdb_val{};
assert (is_end_sentinal ());
debug_assert (is_end_sentinal ());
}
nano::rocksdb_iterator<T, U> & operator= (nano::rocksdb_iterator<T, U> && other_a)
{

View file

@ -166,5 +166,5 @@ void nano::signature_checker::set_thread_names (unsigned num_threads)
{
future.wait ();
}
assert (pending == 0);
debug_assert (pending == 0);
}

View file

@ -66,7 +66,7 @@ void nano::socket::async_read (std::shared_ptr<std::vector<uint8_t>> buffer_a, s
}
else
{
assert (false && "nano::socket::async_read called with incorrect buffer size");
debug_assert (false && "nano::socket::async_read called with incorrect buffer size");
boost::system::error_code ec_buffer = boost::system::errc::make_error_code (boost::system::errc::no_buffer_space);
callback_a (ec_buffer, 0);
}
@ -378,6 +378,6 @@ void nano::server_socket::on_connection (std::function<bool(std::shared_ptr<nano
// This must be called from a strand
void nano::server_socket::evict_dead_connections ()
{
assert (strand.running_in_this_thread ());
debug_assert (strand.running_in_this_thread ());
connections.erase (std::remove_if (connections.begin (), connections.end (), [](auto & connection) { return connection.expired (); }), connections.end ());
}

View file

@ -8,7 +8,6 @@
#include <boost/algorithm/string.hpp>
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <future>
#include <numeric>
@ -239,7 +238,7 @@ void nano::telemetry::get_metrics_single_peer_async (std::shared_ptr<nano::trans
auto const error = !telemetry_data_responses_a.all_received;
if (!error)
{
assert (telemetry_data_responses_a.telemetry_data_time_pairs.size () == 1);
debug_assert (telemetry_data_responses_a.telemetry_data_time_pairs.size () == 1);
auto it = telemetry_data_responses_a.telemetry_data_time_pairs.begin ();
callback_a ({ it->second, it->first, error });
}
@ -338,7 +337,7 @@ void nano::telemetry_impl::get_metrics_async (std::deque<std::shared_ptr<nano::t
}
failed.clear ();
assert (required_responses.empty ());
debug_assert (required_responses.empty ());
std::transform (channels_a.begin (), channels_a.end (), std::inserter (required_responses, required_responses.end ()), [](auto const & channel) {
return channel->get_endpoint ();
});
@ -392,11 +391,11 @@ void nano::telemetry_impl::invoke_callbacks ()
void nano::telemetry_impl::channel_processed (nano::unique_lock<std::mutex> & lk_a, nano::endpoint const & endpoint_a)
{
assert (lk_a.owns_lock ());
debug_assert (lk_a.owns_lock ());
auto num_removed = required_responses.erase (endpoint_a);
if (num_removed > 0 && required_responses.empty ())
{
assert (lk_a.owns_lock ());
debug_assert (lk_a.owns_lock ());
cached_telemetry_data = current_telemetry_data_responses;
last_time = std::chrono::steady_clock::now ();
@ -417,7 +416,7 @@ void nano::telemetry_impl::fire_request_messages (std::deque<std::shared_ptr<nan
nano::telemetry_req message;
for (auto & channel : channels)
{
assert (channel->get_network_version () >= network_params.protocol.telemetry_protocol_version_min);
debug_assert (channel->get_network_version () >= network_params.protocol.telemetry_protocol_version_min);
std::weak_ptr<nano::telemetry_impl> this_w (shared_from_this ());
// clang-format off
@ -659,7 +658,7 @@ nano::telemetry_data_time_pair nano::consolidate_telemetry_data_time_pairs (std:
// May only have major version, but check for optional parameters as well, only output if all are used
std::vector<std::string> version_fragments;
boost::split (version_fragments, version, boost::is_any_of ("."));
assert (!version_fragments.empty () && version_fragments.size () <= 5);
debug_assert (!version_fragments.empty () && version_fragments.size () <= 5);
consolidated_data.major_version = boost::lexical_cast<uint8_t> (version_fragments.front ());
if (version_fragments.size () == 5)
{

View file

@ -30,7 +30,7 @@ std::shared_ptr<nano::node> nano::system::add_node (nano::node_flags node_flags_
std::shared_ptr<nano::node> nano::system::add_node (nano::node_config const & node_config_a, nano::node_flags node_flags_a, nano::transport::transport_type type_a)
{
auto node (std::make_shared<nano::node> (io_ctx, nano::unique_path (), alarm, node_config_a, work, node_flags_a));
assert (!node->init_error ());
debug_assert (!node->init_error ());
node->start ();
node->wallets.create (nano::random_wallet_id ());
nodes.reserve (nodes.size () + 1);
@ -82,7 +82,7 @@ std::shared_ptr<nano::node> nano::system::add_node (nano::node_config const & no
{
poll ();
++iterations1;
assert (iterations1 < 10000);
debug_assert (iterations1 < 10000);
}
}
else
@ -92,7 +92,7 @@ std::shared_ptr<nano::node> nano::system::add_node (nano::node_config const & no
{
poll ();
++iterations1;
assert (iterations1 < 10000);
debug_assert (iterations1 < 10000);
}
}
@ -143,10 +143,10 @@ nano::system::~system ()
std::shared_ptr<nano::wallet> nano::system::wallet (size_t index_a)
{
assert (nodes.size () > index_a);
debug_assert (nodes.size () > index_a);
auto size (nodes[index_a]->wallets.items.size ());
(void)size;
assert (size == 1);
debug_assert (size == 1);
return nodes[index_a]->wallets.items.begin ()->second;
}
@ -154,9 +154,9 @@ nano::account nano::system::account (nano::transaction const & transaction_a, si
{
auto wallet_l (wallet (index_a));
auto keys (wallet_l->store.begin (transaction_a));
assert (keys != wallet_l->store.end ());
debug_assert (keys != wallet_l->store.end ());
auto result (keys->first);
assert (++keys == wallet_l->store.end ());
debug_assert (++keys == wallet_l->store.end ());
return nano::account (result);
}
@ -219,8 +219,8 @@ void nano::system::generate_usage_traffic (uint32_t count_a, uint32_t wait_a)
void nano::system::generate_usage_traffic (uint32_t count_a, uint32_t wait_a, size_t index_a)
{
assert (nodes.size () > index_a);
assert (count_a > 0);
debug_assert (nodes.size () > index_a);
debug_assert (count_a > 0);
auto generate (std::make_shared<traffic_generator> (count_a, wait_a, nodes[index_a], *this));
generate->run ();
}
@ -228,7 +228,7 @@ void nano::system::generate_usage_traffic (uint32_t count_a, uint32_t wait_a, si
void nano::system::generate_rollback (nano::node & node_a, std::vector<nano::account> & accounts_a)
{
auto transaction (node_a.store.tx_begin_write ());
assert (std::numeric_limits<CryptoPP::word32>::max () > accounts_a.size ());
debug_assert (std::numeric_limits<CryptoPP::word32>::max () > accounts_a.size ());
auto index (random_pool::generate_word32 (0, static_cast<CryptoPP::word32> (accounts_a.size () - 1)));
auto account (accounts_a[index]);
nano::account_info info;
@ -244,7 +244,7 @@ void nano::system::generate_rollback (nano::node & node_a, std::vector<nano::acc
std::vector<std::shared_ptr<nano::block>> rollback_list;
auto error = node_a.ledger.rollback (transaction, hash, rollback_list);
(void)error;
assert (!error);
debug_assert (!error);
for (auto & i : rollback_list)
{
node_a.wallets.watcher->remove (i);
@ -306,7 +306,7 @@ void nano::system::generate_activity (nano::node & node_a, std::vector<nano::acc
nano::account nano::system::get_random_account (std::vector<nano::account> & accounts_a)
{
assert (std::numeric_limits<CryptoPP::word32>::max () > accounts_a.size ());
debug_assert (std::numeric_limits<CryptoPP::word32>::max () > accounts_a.size ());
auto index (random_pool::generate_word32 (0, static_cast<CryptoPP::word32> (accounts_a.size () - 1)));
auto result (accounts_a[index]);
return result;
@ -334,7 +334,7 @@ void nano::system::generate_send_existing (nano::node & node_a, std::vector<nano
{
entry = node_a.store.latest_begin (transaction);
}
assert (entry != node_a.store.latest_end ());
debug_assert (entry != node_a.store.latest_end ());
destination = nano::account (entry->first);
source = get_random_account (accounts_a);
amount = get_random_amount (transaction, node_a, source);
@ -343,7 +343,7 @@ void nano::system::generate_send_existing (nano::node & node_a, std::vector<nano
{
auto hash (wallet (0)->send_sync (source, destination, amount));
(void)hash;
assert (!hash.is_zero ());
debug_assert (!hash.is_zero ());
}
}
@ -355,7 +355,7 @@ void nano::system::generate_change_known (nano::node & node_a, std::vector<nano:
nano::account destination (get_random_account (accounts_a));
auto change_error (wallet (0)->change_sync (source, destination));
(void)change_error;
assert (!change_error);
debug_assert (!change_error);
}
}
@ -368,13 +368,13 @@ void nano::system::generate_change_unknown (nano::node & node_a, std::vector<nan
nano::account destination (key.pub);
auto change_error (wallet (0)->change_sync (source, destination));
(void)change_error;
assert (!change_error);
debug_assert (!change_error);
}
}
void nano::system::generate_send_new (nano::node & node_a, std::vector<nano::account> & accounts_a)
{
assert (node_a.wallets.items.size () == 1);
debug_assert (node_a.wallets.items.size () == 1);
nano::uint128_t amount;
nano::account source;
{
@ -388,7 +388,7 @@ void nano::system::generate_send_new (nano::node & node_a, std::vector<nano::acc
accounts_a.push_back (pub);
auto hash (wallet (0)->send_sync (source, pub, amount));
(void)hash;
assert (!hash.is_zero ());
debug_assert (!hash.is_zero ());
}
}

View file

@ -101,7 +101,7 @@ node (node_a)
bool nano::transport::tcp_channels::insert (std::shared_ptr<nano::transport::channel_tcp> channel_a, std::shared_ptr<nano::socket> socket_a, std::shared_ptr<nano::bootstrap_server> bootstrap_server_a)
{
auto endpoint (channel_a->get_tcp_endpoint ());
assert (endpoint.address ().is_v6 ());
debug_assert (endpoint.address ().is_v6 ());
auto udp_endpoint (nano::transport::map_tcp_to_endpoint (endpoint));
bool error (true);
if (!node.network.not_a_peer (udp_endpoint, node.config.allow_local_peers) && !stopped)
@ -181,15 +181,15 @@ std::unordered_set<std::shared_ptr<nano::transport::channel>> nano::transport::t
void nano::transport::tcp_channels::random_fill (std::array<nano::endpoint, 8> & target_a) const
{
auto peers (random_set (target_a.size ()));
assert (peers.size () <= target_a.size ());
debug_assert (peers.size () <= target_a.size ());
auto endpoint (nano::endpoint (boost::asio::ip::address_v6{}, 0));
assert (endpoint.address ().is_v6 ());
debug_assert (endpoint.address ().is_v6 ());
std::fill (target_a.begin (), target_a.end (), endpoint);
auto j (target_a.begin ());
for (auto i (peers.begin ()), n (peers.end ()); i != n; ++i, ++j)
{
assert ((*i)->get_endpoint ().address ().is_v6 ());
assert (j < target_a.end ());
debug_assert ((*i)->get_endpoint ().address ().is_v6 ());
debug_assert (j < target_a.end ());
*j = (*i)->get_endpoint ();
}
}
@ -279,13 +279,13 @@ void nano::transport::tcp_channels::process_message (nano::message const & messa
// Add temporary channel
socket_a->set_writer_concurrency (nano::socket::concurrency::multi_writer);
auto temporary_channel (std::make_shared<nano::transport::channel_tcp> (node, socket_a));
assert (endpoint_a == temporary_channel->get_tcp_endpoint ());
debug_assert (endpoint_a == temporary_channel->get_tcp_endpoint ());
temporary_channel->set_node_id (node_id_a);
temporary_channel->set_network_version (message_a.header.version_using);
temporary_channel->set_last_packet_received (std::chrono::steady_clock::now ());
temporary_channel->set_last_packet_sent (std::chrono::steady_clock::now ());
temporary_channel->temporary = true;
assert (type_a == nano::bootstrap_server_type::realtime || type_a == nano::bootstrap_server_type::realtime_response_server);
debug_assert (type_a == nano::bootstrap_server_type::realtime || type_a == nano::bootstrap_server_type::realtime_response_server);
// Don't insert temporary channels for response_server
if (type_a == nano::bootstrap_server_type::realtime)
{
@ -296,8 +296,8 @@ void nano::transport::tcp_channels::process_message (nano::message const & messa
else
{
// Initial node_id_handshake request without node ID
assert (message_a.header.type == nano::message_type::node_id_handshake);
assert (type_a == nano::bootstrap_server_type::undefined);
debug_assert (message_a.header.type == nano::message_type::node_id_handshake);
debug_assert (type_a == nano::bootstrap_server_type::undefined);
node.stats.inc (nano::stat::type::message, nano::stat::detail::node_id_handshake, nano::stat::dir::in);
}
}

View file

@ -163,7 +163,7 @@ namespace transport
nano::account node_id () const
{
auto node_id (channel->get_node_id ());
assert (!node_id.is_zero ());
debug_assert (!node_id.is_zero ());
return node_id;
}
};

View file

@ -119,7 +119,7 @@ boost::asio::ip::address_v6 mapped_from_v4_bytes (unsigned long address_a)
bool nano::transport::reserved_address (nano::endpoint const & endpoint_a, bool allow_local_peers)
{
assert (endpoint_a.address ().is_v6 ());
debug_assert (endpoint_a.address ().is_v6 ());
auto bytes (endpoint_a.address ().to_v6 ());
auto result (false);
static auto const rfc1700_min (mapped_from_v4_bytes (0x00000000ul));

View file

@ -13,7 +13,7 @@ endpoint (endpoint_a),
channels (channels_a)
{
set_network_version (protocol_version_a);
assert (endpoint_a.address ().is_v6 ());
debug_assert (endpoint_a.address ().is_v6 ());
}
size_t nano::transport::channel_udp::hash_code () const
@ -102,7 +102,7 @@ void nano::transport::udp_channels::send (nano::shared_const_buffer const & buff
std::shared_ptr<nano::transport::channel_udp> nano::transport::udp_channels::insert (nano::endpoint const & endpoint_a, unsigned network_version_a)
{
assert (endpoint_a.address ().is_v6 ());
debug_assert (endpoint_a.address ().is_v6 ());
std::shared_ptr<nano::transport::channel_udp> result;
if (!node.network.not_a_peer (endpoint_a, node.config.allow_local_peers) && (node.network_params.network.is_test_network () || !max_ip_connections (endpoint_a)))
{
@ -175,15 +175,15 @@ std::unordered_set<std::shared_ptr<nano::transport::channel>> nano::transport::u
void nano::transport::udp_channels::random_fill (std::array<nano::endpoint, 8> & target_a) const
{
auto peers (random_set (target_a.size ()));
assert (peers.size () <= target_a.size ());
debug_assert (peers.size () <= target_a.size ());
auto endpoint (nano::endpoint (boost::asio::ip::address_v6{}, 0));
assert (endpoint.address ().is_v6 ());
debug_assert (endpoint.address ().is_v6 ());
std::fill (target_a.begin (), target_a.end (), endpoint);
auto j (target_a.begin ());
for (auto i (peers.begin ()), n (peers.end ()); i != n; ++i, ++j)
{
assert ((*i)->get_endpoint ().address ().is_v6 ());
assert (j < target_a.end ());
debug_assert ((*i)->get_endpoint ().address ().is_v6 ());
debug_assert (j < target_a.end ());
*j = (*i)->get_endpoint ();
}
}
@ -315,7 +315,7 @@ void nano::transport::udp_channels::receive ()
void nano::transport::udp_channels::start ()
{
assert (!node.flags.disable_udp);
debug_assert (!node.flags.disable_udp);
for (size_t i = 0; i < node.config.io_threads && !stopped; ++i)
{
boost::asio::post (strand, [this]() {
@ -418,19 +418,19 @@ public:
}
void bulk_pull (nano::bulk_pull const &) override
{
assert (false);
debug_assert (false);
}
void bulk_pull_account (nano::bulk_pull_account const &) override
{
assert (false);
debug_assert (false);
}
void bulk_push (nano::bulk_push const &) override
{
assert (false);
debug_assert (false);
}
void frontier_req (nano::frontier_req const &) override
{
assert (false);
debug_assert (false);
}
void telemetry_req (nano::telemetry_req const & message_a) override
{

View file

@ -166,7 +166,7 @@ void nano::vote_processor::verify_votes (decltype (votes) const & votes_a)
auto i (0);
for (auto const & vote : votes_a)
{
assert (verifications[i] == 1 || verifications[i] == 0);
debug_assert (verifications[i] == 1 || verifications[i] == 0);
if (verifications[i] == 1)
{
vote_blocking (vote.first, vote.second, true);

View file

@ -111,7 +111,7 @@ void nano::votes_cache::add (std::shared_ptr<nano::vote> const & vote_a)
{
nano::lock_guard<std::mutex> lock (cache_mutex);
auto voting (wallets.rep_counts ().voting);
assert (voting > 0);
debug_assert (voting > 0);
auto const max_cache_size (network_params.voting.max_cache / std::max (voting, static_cast<decltype (voting)> (1)));
for (auto & block : vote_a->blocks)
{
@ -127,7 +127,7 @@ void nano::votes_cache::add (std::shared_ptr<nano::vote> const & vote_a)
// Insert new votes (new hash)
auto inserted (cache.get<tag_sequence> ().emplace_back (nano::cached_votes{ hash, std::vector<std::shared_ptr<nano::vote>> (1, vote_a) }));
(void)inserted;
assert (inserted.second);
debug_assert (inserted.second);
}
else
{

View file

@ -88,7 +88,7 @@ nano::public_key nano::wallet_store::deterministic_insert (nano::transaction con
nano::private_key nano::wallet_store::deterministic_key (nano::transaction const & transaction_a, uint32_t index_a)
{
assert (valid_password (transaction_a));
debug_assert (valid_password (transaction_a));
nano::raw_key seed_l;
seed (seed_l, transaction_a);
return nano::deterministic_key (seed_l, index_a);
@ -166,7 +166,7 @@ bool nano::wallet_store::attempt_password (nano::transaction const & transaction
case version_4:
break;
default:
assert (false);
debug_assert (false);
}
}
return result;
@ -226,7 +226,7 @@ void nano::fan::value (nano::raw_key & prv_a)
void nano::fan::value_get (nano::raw_key & prv_a)
{
assert (!mutex.try_lock ());
debug_assert (!mutex.try_lock ());
prv_a.data.clear ();
for (auto & i : values)
{
@ -271,7 +271,7 @@ kdf (kdf_a)
if (!init_a)
{
MDB_val junk;
assert (mdb_get (tx (transaction_a), handle, nano::mdb_val (version_special), &junk) == MDB_NOTFOUND);
debug_assert (mdb_get (tx (transaction_a), handle, nano::mdb_val (version_special), &junk) == MDB_NOTFOUND);
boost::property_tree::ptree wallet_l;
std::stringstream istream (json_a);
try
@ -378,7 +378,7 @@ std::vector<nano::account> nano::wallet_store::accounts (nano::transaction const
void nano::wallet_store::initialize (nano::transaction const & transaction_a, bool & init_a, std::string const & path_a)
{
assert (strlen (path_a.c_str ()) == path_a.size ());
debug_assert (strlen (path_a.c_str ()) == path_a.size ());
auto error (0);
error |= mdb_dbi_open (tx (transaction_a), path_a.c_str (), MDB_CREATE, &handle);
init_a = error != 0;
@ -402,7 +402,7 @@ nano::account nano::wallet_store::representative (nano::transaction const & tran
nano::public_key nano::wallet_store::insert_adhoc (nano::transaction const & transaction_a, nano::raw_key const & prv)
{
assert (valid_password (transaction_a));
debug_assert (valid_password (transaction_a));
nano::public_key pub (nano::pub_key (prv.as_private_key ()));
nano::raw_key password_l;
wallet_key (password_l, transaction_a);
@ -426,7 +426,7 @@ void nano::wallet_store::erase (nano::transaction const & transaction_a, nano::a
{
auto status (mdb_del (tx (transaction_a), handle, nano::mdb_val (pub), nullptr));
(void)status;
assert (status == 0);
debug_assert (status == 0);
}
nano::wallet_value nano::wallet_store::entry_get_raw (nano::transaction const & transaction_a, nano::account const & pub_a)
@ -450,7 +450,7 @@ void nano::wallet_store::entry_put_raw (nano::transaction const & transaction_a,
{
auto status (mdb_put (tx (transaction_a), handle, nano::mdb_val (pub_a), nano::mdb_val (sizeof (entry_a), const_cast<nano::wallet_value *> (&entry_a)), 0));
(void)status;
assert (status == 0);
debug_assert (status == 0);
}
nano::key_type nano::wallet_store::key_type (nano::wallet_value const & value_a)
@ -569,8 +569,8 @@ void nano::wallet_store::write_backup (nano::transaction const & transaction_a,
bool nano::wallet_store::move (nano::transaction const & transaction_a, nano::wallet_store & other_a, std::vector<nano::public_key> const & keys)
{
assert (valid_password (transaction_a));
assert (other_a.valid_password (transaction_a));
debug_assert (valid_password (transaction_a));
debug_assert (other_a.valid_password (transaction_a));
auto result (false);
for (auto i (keys.begin ()), n (keys.end ()); i != n; ++i)
{
@ -588,8 +588,8 @@ bool nano::wallet_store::move (nano::transaction const & transaction_a, nano::wa
bool nano::wallet_store::import (nano::transaction const & transaction_a, nano::wallet_store & other_a)
{
assert (valid_password (transaction_a));
assert (other_a.valid_password (transaction_a));
debug_assert (valid_password (transaction_a));
debug_assert (other_a.valid_password (transaction_a));
auto result (false);
for (auto i (other_a.begin (transaction_a)), n (end ()); i != n; ++i)
{
@ -630,7 +630,7 @@ bool nano::wallet_store::work_get (nano::transaction const & transaction_a, nano
void nano::wallet_store::work_put (nano::transaction const & transaction_a, nano::public_key const & pub_a, uint64_t work_a)
{
auto entry (entry_get_raw (transaction_a, pub_a));
assert (!entry.key.is_zero ());
debug_assert (!entry.key.is_zero ());
entry.work = work_a;
entry_put_raw (transaction_a, pub_a, entry);
}
@ -651,7 +651,7 @@ void nano::wallet_store::version_put (nano::transaction const & transaction_a, u
void nano::wallet_store::upgrade_v1_v2 (nano::transaction const & transaction_a)
{
assert (version (transaction_a) == 1);
debug_assert (version (transaction_a) == 1);
nano::raw_key zero_password;
nano::wallet_value value (entry_get_raw (transaction_a, nano::wallet_store::wallet_key_special));
nano::raw_key kdf;
@ -694,7 +694,7 @@ void nano::wallet_store::upgrade_v1_v2 (nano::transaction const & transaction_a)
void nano::wallet_store::upgrade_v2_v3 (nano::transaction const & transaction_a)
{
assert (version (transaction_a) == 2);
debug_assert (version (transaction_a) == 2);
nano::raw_key seed;
random_pool::generate_block (seed.data.bytes.data (), seed.data.bytes.size ());
seed_set (transaction_a, seed);
@ -704,9 +704,9 @@ void nano::wallet_store::upgrade_v2_v3 (nano::transaction const & transaction_a)
void nano::wallet_store::upgrade_v3_v4 (nano::transaction const & transaction_a)
{
assert (version (transaction_a) == 3);
debug_assert (version (transaction_a) == 3);
version_put (transaction_a, 4);
assert (valid_password (transaction_a));
debug_assert (valid_password (transaction_a));
nano::raw_key seed;
nano::wallet_value value (entry_get_raw (transaction_a, nano::wallet_store::seed_special));
nano::raw_key password_l;
@ -739,7 +739,7 @@ void nano::wallet_store::upgrade_v3_v4 (nano::transaction const & transaction_a)
case nano::key_type::deterministic:
break;
default:
assert (false);
debug_assert (false);
}
}
}
@ -750,7 +750,7 @@ void nano::kdf::phs (nano::raw_key & result_a, std::string const & password_a, n
static nano::network_params network_params;
nano::lock_guard<std::mutex> lock (mutex);
auto success (argon2_hash (1, network_params.kdf_work, 1, password_a.data (), password_a.size (), salt_a.bytes.data (), salt_a.bytes.size (), result_a.data.bytes.data (), result_a.data.bytes.size (), NULL, 0, Argon2_d, 0x10));
assert (success == 0);
debug_assert (success == 0);
(void)success;
}
@ -924,7 +924,7 @@ void nano::wallet_store::destroy (nano::transaction const & transaction_a)
{
auto status (mdb_drop (tx (transaction_a), handle, 1));
(void)status;
assert (status == 0);
debug_assert (status == 0);
handle = 0;
}
@ -1006,11 +1006,11 @@ std::shared_ptr<nano::block> nano::wallet::change_action (nano::account const &
nano::account_info info;
auto error1 (wallets.node.ledger.store.account_get (block_transaction, source_a, info));
(void)error1;
assert (!error1);
debug_assert (!error1);
nano::raw_key prv;
auto error2 (store.fetch (transaction, source_a, prv));
(void)error2;
assert (!error2);
debug_assert (!error2);
if (work_a == 0)
{
store.work_get (transaction, source_a, work_a);
@ -1075,11 +1075,11 @@ std::shared_ptr<nano::block> nano::wallet::send_action (nano::account const & so
nano::account_info info;
auto error1 (wallets.node.ledger.store.account_get (block_transaction, source_a, info));
(void)error1;
assert (!error1);
debug_assert (!error1);
nano::raw_key prv;
auto error2 (store.fetch (transaction, source_a, prv));
(void)error2;
assert (!error2);
debug_assert (!error2);
if (work_a == 0)
{
store.work_get (transaction, source_a, work_a);
@ -1217,8 +1217,8 @@ void nano::wallet::send_async (nano::account const & source_a, nano::account con
// Update work for account if latest root is root_a
void nano::wallet::work_update (nano::transaction const & transaction_a, nano::account const & account_a, nano::root const & root_a, uint64_t work_a)
{
assert (!nano::work_validate (nano::work_version::work_1, root_a, work_a));
assert (store.exists (transaction_a, account_a));
debug_assert (!nano::work_validate (nano::work_version::work_1, root_a, work_a));
debug_assert (store.exists (transaction_a, account_a));
auto block_transaction (wallets.node.store.tx_begin_read ());
auto latest (wallets.node.ledger.latest_root (block_transaction, account_a));
if (latest == root_a)
@ -1547,7 +1547,7 @@ thread ([this]() {
auto status (mdb_dbi_open (env.tx (transaction), nullptr, MDB_CREATE, &handle));
split_if_needed (transaction, node.store);
status |= mdb_dbi_open (env.tx (transaction), "send_action_ids", MDB_CREATE, &send_action_ids);
assert (status == 0);
debug_assert (status == 0);
std::string beginning (nano::uint256_union (0).to_string ());
std::string end ((nano::uint256_union (nano::uint256_t (0) - nano::uint256_t (1))).to_string ());
nano::store_iterator<std::array<char, 64>, nano::no_value> i (std::make_unique<nano::mdb_iterator<std::array<char, 64>, nano::no_value>> (transaction, handle, nano::mdb_val (beginning.size (), const_cast<char *> (beginning.c_str ()))));
@ -1557,8 +1557,8 @@ thread ([this]() {
nano::wallet_id id;
std::string text (i->first.data (), i->first.size ());
auto error (id.decode_hex (text));
assert (!error);
assert (items.find (id) == items.end ());
debug_assert (!error);
debug_assert (items.find (id) == items.end ());
auto wallet (std::make_shared<nano::wallet> (error, transaction, *this, text));
if (!error)
{
@ -1622,7 +1622,7 @@ std::shared_ptr<nano::wallet> nano::wallets::open (nano::wallet_id const & id_a)
std::shared_ptr<nano::wallet> nano::wallets::create (nano::wallet_id const & id_a)
{
nano::lock_guard<std::mutex> lock (mutex);
assert (items.find (id_a) == items.end ());
debug_assert (items.find (id_a) == items.end ());
std::shared_ptr<nano::wallet> result;
bool error;
{
@ -1667,7 +1667,7 @@ void nano::wallets::destroy (nano::wallet_id const & id_a)
// action_mutex should be after transactions to prevent deadlocks in deterministic_insert () & insert_adhoc ()
nano::lock_guard<std::mutex> action_lock (action_mutex);
auto existing (items.find (id_a));
assert (existing != items.end ());
debug_assert (existing != items.end ());
auto wallet (existing->second);
items.erase (existing);
wallet->store.destroy (transaction);
@ -1687,7 +1687,7 @@ void nano::wallets::reload ()
nano::wallet_id id;
std::string text (i->first.data (), i->first.size ());
auto error (id.decode_hex (text));
assert (!error);
debug_assert (!error);
// New wallet
if (items.find (id) == items.end ())
{
@ -1711,7 +1711,7 @@ void nano::wallets::reload ()
}
for (auto & i : deleted_items)
{
assert (items.find (i) == items.end ());
debug_assert (items.find (i) == items.end ());
items.erase (i);
}
}
@ -1751,7 +1751,7 @@ void nano::wallets::foreach_representative (std::function<void(nano::public_key
nano::raw_key prv;
auto error (wallet.store.fetch (transaction_l, account, prv));
(void)error;
assert (!error);
debug_assert (!error);
action_a (account, prv);
}
else
@ -1810,7 +1810,7 @@ void nano::wallets::clear_send_ids (nano::transaction const & transaction_a)
{
auto status (mdb_drop (env.tx (transaction_a), send_action_ids, 0));
(void)status;
assert (status == 0);
debug_assert (status == 0);
}
nano::wallet_representative_counts nano::wallets::rep_counts ()
@ -1910,8 +1910,8 @@ void nano::wallets::split_if_needed (nano::transaction & transaction_destination
std::string text (i->first.data (), i->first.size ());
auto error1 (id.decode_hex (text));
(void)error1;
assert (!error1);
assert (strlen (text.c_str ()) == text.size ());
debug_assert (!error1);
debug_assert (strlen (text.c_str ()) == text.size ());
move_table (text, tx_source, tx_destination);
}
}
@ -1924,15 +1924,15 @@ void nano::wallets::move_table (std::string const & name_a, MDB_txn * tx_source,
MDB_dbi handle_source;
auto error2 (mdb_dbi_open (tx_source, name_a.c_str (), MDB_CREATE, &handle_source));
(void)error2;
assert (!error2);
debug_assert (!error2);
MDB_dbi handle_destination;
auto error3 (mdb_dbi_open (tx_destination, name_a.c_str (), MDB_CREATE, &handle_destination));
(void)error3;
assert (!error3);
debug_assert (!error3);
MDB_cursor * cursor;
auto error4 (mdb_cursor_open (tx_source, handle_source, &cursor));
(void)error4;
assert (!error4);
debug_assert (!error4);
MDB_val val_key;
MDB_val val_value;
auto cursor_status (mdb_cursor_get (cursor, &val_key, &val_value, MDB_FIRST));
@ -1940,12 +1940,12 @@ void nano::wallets::move_table (std::string const & name_a, MDB_txn * tx_source,
{
auto error5 (mdb_put (tx_destination, handle_destination, &val_key, &val_value, 0));
(void)error5;
assert (!error5);
debug_assert (!error5);
cursor_status = mdb_cursor_get (cursor, &val_key, &val_value, MDB_NEXT);
}
auto error6 (mdb_drop (tx_source, handle_source, 1));
(void)error6;
assert (!error6);
debug_assert (!error6);
}
nano::uint128_t const nano::wallets::generate_priority = std::numeric_limits<nano::uint128_t>::max ();

View file

@ -118,7 +118,7 @@ bool nano::websocket::confirmation_options::should_filter (nano::websocket::mess
auto decode_destination_ok_l (!destination_l.decode_account (destination_opt_l.get ()));
(void)decode_source_ok_l;
(void)decode_destination_ok_l;
assert (decode_source_ok_l && decode_destination_ok_l);
debug_assert (decode_source_ok_l && decode_destination_ok_l);
if (wallets.exists (transaction_l, source_l) || wallets.exists (transaction_l, destination_l))
{
should_filter_account = false;
@ -624,7 +624,7 @@ void nano::websocket::listener::broadcast_confirmation (std::shared_ptr<nano::bl
}
else
{
assert (false);
debug_assert (false);
}
session_ptr->write (include_block ? msg_with_block.get () : msg_without_block.get ());
@ -749,7 +749,7 @@ nano::websocket::message nano::websocket::message_builder::vote_received (std::s
vote_type = "indeterminate";
break;
case nano::vote_code::invalid:
assert (false);
debug_assert (false);
break;
}
vote_node_l.put ("type", vote_type);

View file

@ -43,7 +43,7 @@ void show_button_success (QPushButton & button)
bool nano_qt::eventloop_processor::event (QEvent * event_a)
{
assert (dynamic_cast<nano_qt::eventloop_event *> (event_a) != nullptr);
debug_assert (dynamic_cast<nano_qt::eventloop_event *> (event_a) != nullptr);
static_cast<nano_qt::eventloop_event *> (event_a)->action ();
return true;
}
@ -163,7 +163,7 @@ wallet (wallet_a)
{
auto error (this->wallet.account.decode_account (model->item (selection[0].row (), 1)->text ().toStdString ()));
(void)error;
assert (!error);
debug_assert (!error);
this->wallet.refresh ();
}
});
@ -599,7 +599,7 @@ void nano_qt::history::refresh ()
{
QList<QStandardItem *> items;
auto block (ledger.store.block_get (transaction, hash));
assert (block != nullptr);
debug_assert (block != nullptr);
block->visit (visitor);
items.push_back (new QStandardItem (QString (visitor.type.c_str ())));
items.push_back (new QStandardItem (QString (visitor.account.to_account ().c_str ())));
@ -868,7 +868,7 @@ wallet (wallet_a)
void nano_qt::status::erase (nano_qt::status_types status_a)
{
assert (status_a != nano_qt::status_types::nominal);
debug_assert (status_a != nano_qt::status_types::nominal);
auto erased (active.erase (status_a));
(void)erased;
set_text ();
@ -876,7 +876,7 @@ void nano_qt::status::erase (nano_qt::status_types status_a)
void nano_qt::status::insert (nano_qt::status_types status_a)
{
assert (status_a != nano_qt::status_types::nominal);
debug_assert (status_a != nano_qt::status_types::nominal);
active.insert (status_a);
set_text ();
}
@ -889,7 +889,7 @@ void nano_qt::status::set_text ()
std::string nano_qt::status::text ()
{
assert (!active.empty ());
debug_assert (!active.empty ());
std::string result;
size_t unchecked (0);
std::string count_string;
@ -923,7 +923,7 @@ std::string nano_qt::status::text ()
result = "Status: Running";
break;
default:
assert (false);
debug_assert (false);
break;
}
@ -939,7 +939,7 @@ std::string nano_qt::status::text ()
std::string nano_qt::status::color ()
{
assert (!active.empty ());
debug_assert (!active.empty ());
std::string result;
switch (*active.begin ())
{
@ -965,7 +965,7 @@ std::string nano_qt::status::color ()
result = "color: black";
break;
default:
assert (false);
debug_assert (false);
break;
}
return result;
@ -1387,7 +1387,7 @@ void nano_qt::wallet::refresh ()
{
{
auto transaction (wallet_m->wallets.tx_begin_read ());
assert (wallet_m->store.exists (transaction, account));
debug_assert (wallet_m->store.exists (transaction, account));
}
self.account_text->setText (QString (account.to_account ().c_str ()));
needs_balance_refresh = true;
@ -1603,7 +1603,7 @@ wallet (wallet_a)
}
});
QObject::connect (back, &QPushButton::released, [this]() {
assert (this->wallet.main_stack->currentWidget () == window);
debug_assert (this->wallet.main_stack->currentWidget () == window);
this->wallet.pop_main_stack ();
});
QObject::connect (lock_toggle, &QPushButton::released, [this]() {
@ -1843,7 +1843,7 @@ wallet (wallet_a)
});
auto selected_ratio_id (QSettings ().value (saved_ratio_key, ratio_group->id (mnano_unit)).toInt ());
auto selected_ratio_button = ratio_group->button (selected_ratio_id);
assert (selected_ratio_button != nullptr);
debug_assert (selected_ratio_button != nullptr);
if (selected_ratio_button)
{
@ -2120,7 +2120,7 @@ wallet (wallet_a)
create_open ();
break;
default:
assert (false);
debug_assert (false);
break;
}
});
@ -2227,7 +2227,7 @@ void nano_qt::block_creation::create_send ()
nano::account_info info;
auto error (wallet.node.store.account_get (block_transaction, account_l, info));
(void)error;
assert (!error);
debug_assert (!error);
nano::state_block send (account_l, info.head, info.representative, balance - amount_l.number (), destination_l, key, account_l, 0);
if (wallet.node.work_generate_blocking (nano::work_version::work_1, send).is_initialized ())
{

View file

@ -43,7 +43,7 @@ int main (int argc, char ** argv)
catch (...)
{
result = -1;
assert (false);
debug_assert (false);
}
runner.join ();
return result;

View file

@ -3,6 +3,7 @@
#include <nano/lib/logger_mt.hpp>
#include <nano/lib/rpc_handler_interface.hpp>
#include <nano/lib/rpcconfig.hpp>
#include <nano/lib/utility.hpp>
#include <nano/rpc/rpc_connection.hpp>
#include <nano/rpc/rpc_handler.hpp>
@ -51,7 +52,7 @@ void nano::rpc_connection::write_result (std::string body, unsigned version, boo
}
else
{
assert (false && "RPC already responded and should only respond once");
debug_assert (false && "RPC already responded and should only respond once");
}
}

View file

@ -112,7 +112,7 @@ void nano::rpc_handler::process_request (nano::rpc_handler_request_params const
}
else
{
assert (false);
debug_assert (false);
json_error_response (response, "Invalid RPC version");
}
}

View file

@ -6277,7 +6277,7 @@ TEST (rpc, confirmation_history)
ASSERT_EQ (block->hash ().to_string (), hash);
nano::amount tally_num;
tally_num.decode_dec (tally);
assert (tally_num == nano::genesis_amount || tally_num == (nano::genesis_amount - nano::Gxrb_ratio));
debug_assert (tally_num == nano::genesis_amount || tally_num == (nano::genesis_amount - nano::Gxrb_ratio));
system.stop ();
}
@ -6325,7 +6325,7 @@ TEST (rpc, confirmation_history_hash)
ASSERT_EQ (send2->hash ().to_string (), hash);
nano::amount tally_num;
tally_num.decode_dec (tally);
assert (tally_num == nano::genesis_amount || tally_num == (nano::genesis_amount - nano::Gxrb_ratio) || tally_num == (nano::genesis_amount - 2 * nano::Gxrb_ratio) || tally_num == (nano::genesis_amount - 3 * nano::Gxrb_ratio));
debug_assert (tally_num == nano::genesis_amount || tally_num == (nano::genesis_amount - nano::Gxrb_ratio) || tally_num == (nano::genesis_amount - 2 * nano::Gxrb_ratio) || tally_num == (nano::genesis_amount - 3 * nano::Gxrb_ratio));
system.stop ();
}

View file

@ -166,7 +166,7 @@ is_v14_upgrade (is_v14_upgrade_a)
void nano::summation_visitor::send_block (nano::send_block const & block_a)
{
assert (current->type != summation_type::invalid && current != nullptr);
debug_assert (current->type != summation_type::invalid && current != nullptr);
if (current->type == summation_type::amount)
{
sum_set (block_a.hashables.balance.number ());
@ -182,7 +182,7 @@ void nano::summation_visitor::send_block (nano::send_block const & block_a)
void nano::summation_visitor::state_block (nano::state_block const & block_a)
{
assert (current->type != summation_type::invalid && current != nullptr);
debug_assert (current->type != summation_type::invalid && current != nullptr);
sum_set (block_a.hashables.balance.number ());
if (current->type == summation_type::amount)
{
@ -197,7 +197,7 @@ void nano::summation_visitor::state_block (nano::state_block const & block_a)
void nano::summation_visitor::receive_block (nano::receive_block const & block_a)
{
assert (current->type != summation_type::invalid && current != nullptr);
debug_assert (current->type != summation_type::invalid && current != nullptr);
if (current->type == summation_type::amount)
{
current->amount_hash = block_a.hashables.source;
@ -220,7 +220,7 @@ void nano::summation_visitor::receive_block (nano::receive_block const & block_a
void nano::summation_visitor::open_block (nano::open_block const & block_a)
{
assert (current->type != summation_type::invalid && current != nullptr);
debug_assert (current->type != summation_type::invalid && current != nullptr);
if (current->type == summation_type::amount)
{
if (block_a.hashables.source != network_params.ledger.genesis_account)
@ -242,7 +242,7 @@ void nano::summation_visitor::open_block (nano::open_block const & block_a)
void nano::summation_visitor::change_block (nano::change_block const & block_a)
{
assert (current->type != summation_type::invalid && current != nullptr);
debug_assert (current->type != summation_type::invalid && current != nullptr);
if (current->type == summation_type::amount)
{
sum_set (0);
@ -296,7 +296,7 @@ nano::uint128_t nano::summation_visitor::compute_internal (nano::summation_visit
while (!frames.empty ())
{
current = &frames.top ();
assert (current->type != summation_type::invalid && current != nullptr);
debug_assert (current->type != summation_type::invalid && current != nullptr);
if (current->type == summation_type::balance)
{
@ -318,7 +318,7 @@ nano::uint128_t nano::summation_visitor::compute_internal (nano::summation_visit
else
{
auto block (block_get (transaction, current->balance_hash));
assert (block != nullptr);
debug_assert (block != nullptr);
block->visit (*this);
}
}
@ -351,7 +351,7 @@ nano::uint128_t nano::summation_visitor::compute_internal (nano::summation_visit
}
else
{
assert (false);
debug_assert (false);
sum_set (0);
current->amount_hash = 0;
}
@ -413,7 +413,7 @@ void nano::representative_visitor::compute (nano::block_hash const & hash_a)
while (result.is_zero ())
{
auto block (store.block_get (transaction, current));
assert (block != nullptr);
debug_assert (block != nullptr);
block->visit (*this);
}
}
@ -475,7 +475,7 @@ impl (std::move (write_transaction_impl))
/*
* For IO threads, we do not want them to block on creating write transactions.
*/
assert (nano::thread_role::get () != nano::thread_role::name::io);
debug_assert (nano::thread_role::get () != nano::thread_role::name::io);
}
void * nano::write_transaction::get_handle () const

View file

@ -185,7 +185,7 @@ public:
explicit operator nano::account_info () const
{
nano::account_info result;
assert (size () == result.db_size ());
debug_assert (size () == result.db_size ());
std::copy (reinterpret_cast<uint8_t const *> (data ()), reinterpret_cast<uint8_t const *> (data ()) + result.db_size (), reinterpret_cast<uint8_t *> (&result));
return result;
}
@ -193,7 +193,7 @@ public:
explicit operator nano::account_info_v13 () const
{
nano::account_info_v13 result;
assert (size () == result.db_size ());
debug_assert (size () == result.db_size ());
std::copy (reinterpret_cast<uint8_t const *> (data ()), reinterpret_cast<uint8_t const *> (data ()) + result.db_size (), reinterpret_cast<uint8_t *> (&result));
return result;
}
@ -201,7 +201,7 @@ public:
explicit operator nano::account_info_v14 () const
{
nano::account_info_v14 result;
assert (size () == result.db_size ());
debug_assert (size () == result.db_size ());
std::copy (reinterpret_cast<uint8_t const *> (data ()), reinterpret_cast<uint8_t const *> (data ()) + result.db_size (), reinterpret_cast<uint8_t *> (&result));
return result;
}
@ -209,7 +209,7 @@ public:
explicit operator nano::block_info () const
{
nano::block_info result;
assert (size () == sizeof (result));
debug_assert (size () == sizeof (result));
static_assert (sizeof (nano::block_info::account) + sizeof (nano::block_info::balance) == sizeof (result), "Packed class");
std::copy (reinterpret_cast<uint8_t const *> (data ()), reinterpret_cast<uint8_t const *> (data ()) + sizeof (result), reinterpret_cast<uint8_t *> (&result));
return result;
@ -218,7 +218,7 @@ public:
explicit operator nano::pending_info_v14 () const
{
nano::pending_info_v14 result;
assert (size () == result.db_size ());
debug_assert (size () == result.db_size ());
std::copy (reinterpret_cast<uint8_t const *> (data ()), reinterpret_cast<uint8_t const *> (data ()) + result.db_size (), reinterpret_cast<uint8_t *> (&result));
return result;
}
@ -226,7 +226,7 @@ public:
explicit operator nano::pending_info () const
{
nano::pending_info result;
assert (size () == result.db_size ());
debug_assert (size () == result.db_size ());
std::copy (reinterpret_cast<uint8_t const *> (data ()), reinterpret_cast<uint8_t const *> (data ()) + result.db_size (), reinterpret_cast<uint8_t *> (&result));
return result;
}
@ -234,7 +234,7 @@ public:
explicit operator nano::pending_key () const
{
nano::pending_key result;
assert (size () == sizeof (result));
debug_assert (size () == sizeof (result));
static_assert (sizeof (nano::pending_key::account) + sizeof (nano::pending_key::hash) == sizeof (result), "Packed class");
std::copy (reinterpret_cast<uint8_t const *> (data ()), reinterpret_cast<uint8_t const *> (data ()) + sizeof (result), reinterpret_cast<uint8_t *> (&result));
return result;
@ -246,7 +246,7 @@ public:
nano::confirmation_height_info result;
bool error (result.deserialize (stream));
(void)error;
assert (!error);
debug_assert (!error);
return result;
}
@ -256,14 +256,14 @@ public:
nano::unchecked_info result;
bool error (result.deserialize (stream));
(void)error;
assert (!error);
debug_assert (!error);
return result;
}
explicit operator nano::unchecked_key () const
{
nano::unchecked_key result;
assert (size () == sizeof (result));
debug_assert (size () == sizeof (result));
static_assert (sizeof (nano::unchecked_key::previous) + sizeof (nano::pending_key::hash) == sizeof (result), "Packed class");
std::copy (reinterpret_cast<uint8_t const *> (data ()), reinterpret_cast<uint8_t const *> (data ()) + sizeof (result), reinterpret_cast<uint8_t *> (&result));
return result;
@ -300,7 +300,7 @@ public:
std::array<char, 64> result;
auto error = nano::try_read (stream, result);
(void)error;
assert (!error);
debug_assert (!error);
return result;
}
@ -320,11 +320,11 @@ private:
auto error (false);
T block_w_sideband;
block_w_sideband.state_block = std::make_shared<nano::state_block> (error, stream);
assert (!error);
debug_assert (!error);
block_w_sideband.sideband.type = nano::block_type::state;
error = block_w_sideband.sideband.deserialize (stream);
assert (!error);
debug_assert (!error);
return block_w_sideband;
}
@ -358,7 +358,7 @@ public:
nano::bufferstream stream (reinterpret_cast<uint8_t const *> (data ()), size ());
auto error (false);
auto result (std::make_shared<Block> (error, stream));
assert (!error);
debug_assert (!error);
return result;
}
@ -392,7 +392,7 @@ public:
nano::bufferstream stream (reinterpret_cast<uint8_t const *> (data ()), size ());
auto error (false);
auto result (nano::make_shared<nano::vote> (error, stream));
assert (!error);
debug_assert (!error);
return result;
}
@ -402,7 +402,7 @@ public:
nano::bufferstream stream (reinterpret_cast<uint8_t const *> (data ()), size ());
auto error (nano::try_read (stream, result));
(void)error;
assert (!error);
debug_assert (!error);
boost::endian::big_to_native_inplace (result);
return result;
}
@ -432,7 +432,7 @@ private:
T convert () const
{
T result;
assert (size () == sizeof (result));
debug_assert (size () == sizeof (result));
std::copy (reinterpret_cast<uint8_t const *> (data ()), reinterpret_cast<uint8_t const *> (data ()) + sizeof (result), result.bytes.data ());
return result;
}

View file

@ -30,7 +30,7 @@ public:
void initialize (nano::write_transaction const & transaction_a, nano::genesis const & genesis_a, nano::ledger_cache & ledger_cache_a) override
{
auto hash_l (genesis_a.hash ());
assert (latest_begin (transaction_a) == latest_end ());
debug_assert (latest_begin (transaction_a) == latest_end ());
nano::block_sideband sideband (nano::block_type::open, network_params.ledger.genesis_account, 0, network_params.ledger.genesis_amount, 1, nano::seconds_since_epoch (), nano::epoch::epoch_0, false, false, false);
block_put (transaction_a, hash_l, *genesis_a.open, sideband);
++ledger_cache_a.block_count;
@ -99,8 +99,8 @@ public:
void block_put (nano::write_transaction const & transaction_a, nano::block_hash const & hash_a, nano::block const & block_a, nano::block_sideband const & sideband_a) override
{
assert (block_a.type () == sideband_a.type);
assert (sideband_a.successor.is_zero () || block_exists (transaction_a, sideband_a.successor));
debug_assert (block_a.type () == sideband_a.type);
debug_assert (sideband_a.successor.is_zero () || block_exists (transaction_a, sideband_a.successor));
std::vector<uint8_t> vector;
{
nano::vectorstream stream (vector);
@ -110,7 +110,7 @@ public:
block_raw_put (transaction_a, vector, block_a.type (), hash_a);
nano::block_predecessor_set<Val, Derived_Store> predecessor (transaction_a, *this);
block_a.visit (predecessor);
assert (block_a.previous ().is_zero () || block_successor (transaction_a, block_a.previous ()) == hash_a);
debug_assert (block_a.previous ().is_zero () || block_successor (transaction_a, block_a.previous ()) == hash_a);
}
// Converts a block hash to a block height
@ -118,7 +118,7 @@ public:
{
nano::block_sideband sideband;
auto block = block_get (transaction_a, hash_a, &sideband);
assert (block != nullptr);
debug_assert (block != nullptr);
return sideband.height;
}
@ -131,7 +131,7 @@ public:
{
nano::bufferstream stream (reinterpret_cast<uint8_t const *> (value.data ()), value.size ());
result = nano::deserialize_block (stream, type);
assert (result != nullptr);
debug_assert (result != nullptr);
if (sideband_a)
{
sideband_a->type = type;
@ -139,7 +139,7 @@ public:
{
auto error (sideband_a->deserialize (stream));
(void)error;
assert (!error);
debug_assert (!error);
}
else
{
@ -193,7 +193,7 @@ public:
{
result = sideband.account;
}
assert (!result.is_zero ());
debug_assert (!result.is_zero ());
return result;
}
@ -228,11 +228,11 @@ public:
nano::block_hash result;
if (value.size () != 0)
{
assert (value.size () >= result.bytes.size ());
debug_assert (value.size () >= result.bytes.size ());
nano::bufferstream stream (reinterpret_cast<uint8_t const *> (value.data ()) + block_successor_offset (transaction_a, value.size (), type), result.bytes.size ());
auto error (nano::try_read (stream, result.bytes));
(void)error;
assert (!error);
debug_assert (!error);
}
else
{
@ -250,7 +250,7 @@ public:
{
nano::block_type type;
auto value (block_raw_get (transaction_a, hash_a, type));
assert (value.size () != 0);
debug_assert (value.size () != 0);
std::vector<uint8_t> data (static_cast<uint8_t *> (value.data ()), static_cast<uint8_t *> (value.data ()) + value.size ());
std::fill_n (data.begin () + block_successor_offset (transaction_a, value.size (), type), sizeof (nano::block_hash), uint8_t{ 0 });
block_raw_put (transaction_a, data, type, hash_a);
@ -265,7 +265,7 @@ public:
std::shared_ptr<nano::vote> vote_current (nano::transaction const & transaction_a, nano::account const & account_a) override
{
assert (!cache_mutex.try_lock ());
debug_assert (!cache_mutex.try_lock ());
std::shared_ptr<nano::vote> result;
auto existing (vote_cache_l1.find (account_a));
auto have_existing (true);
@ -382,7 +382,7 @@ public:
table = tables::state_blocks;
break;
default:
assert (false);
debug_assert (false);
}
auto status = del (transaction_a, table, hash_a);
@ -398,7 +398,7 @@ public:
if (!not_found (status))
{
nano::uint256_union version_value (data);
assert (version_value.qwords[2] == 0 && version_value.qwords[1] == 0 && version_value.qwords[0] == 0);
debug_assert (version_value.qwords[2] == 0 && version_value.qwords[1] == 0 && version_value.qwords[0] == 0);
result = version_value.number ().convert_to<int> ();
}
return result;
@ -501,7 +501,7 @@ public:
if (success (status))
{
std::shared_ptr<nano::vote> result (value);
assert (result != nullptr);
debug_assert (result != nullptr);
return result;
}
return nullptr;
@ -543,7 +543,7 @@ public:
void account_put (nano::write_transaction const & transaction_a, nano::account const & account_a, nano::account_info const & info_a) override
{
// Check we are still in sync with other tables
assert (confirmation_height_exists (transaction_a, account_a));
debug_assert (confirmation_height_exists (transaction_a, account_a));
nano::db_val<Val> info (info_a);
auto status = put (transaction_a, tables::accounts, account_a, info);
release_assert (success (status));
@ -676,7 +676,7 @@ public:
}
}
}
assert (result != nullptr);
debug_assert (result != nullptr);
return result;
}
@ -794,7 +794,7 @@ protected:
existing = make_iterator<nano::block_hash, std::shared_ptr<T>> (transaction_a, table_a);
}
auto end (nano::store_iterator<nano::block_hash, std::shared_ptr<T>> (nullptr));
assert (existing != end);
debug_assert (existing != end);
return block_get (transaction_a, nano::block_hash (existing->first));
}
@ -837,13 +837,13 @@ protected:
// Return account containing hash
nano::account block_account_computed (nano::transaction const & transaction_a, nano::block_hash const & hash_a) const
{
assert (!full_sideband (transaction_a));
debug_assert (!full_sideband (transaction_a));
nano::account result (0);
auto hash (hash_a);
while (result.is_zero ())
{
auto block (block_get (transaction_a, hash));
assert (block);
debug_assert (block);
result = block->account ();
if (result.is_zero ())
{
@ -866,20 +866,20 @@ protected:
if (result.is_zero ())
{
auto successor (block_successor (transaction_a, hash));
assert (!successor.is_zero ());
debug_assert (!successor.is_zero ());
hash = successor;
}
}
}
}
}
assert (!result.is_zero ());
debug_assert (!result.is_zero ());
return result;
}
nano::uint128_t block_balance_computed (nano::transaction const & transaction_a, nano::block_hash const & hash_a) const
{
assert (!full_sideband (transaction_a));
debug_assert (!full_sideband (transaction_a));
summation_visitor visitor (transaction_a, *this);
return visitor.compute_balance (hash_a);
}
@ -894,7 +894,7 @@ protected:
else
{
// Read old successor-only sideband
assert (entry_size_a == nano::block::size (type_a) + sizeof (nano::block_hash));
debug_assert (entry_size_a == nano::block::size (type_a) + sizeof (nano::block_hash));
result = entry_size_a - sizeof (nano::block_hash);
}
return result;
@ -969,7 +969,7 @@ protected:
result = tables::state_blocks;
break;
default:
assert (false);
debug_assert (false);
break;
}
return result;
@ -1025,7 +1025,7 @@ public:
auto hash (block_a.hash ());
nano::block_type type;
auto value (store.block_raw_get (transaction, block_a.previous (), type));
assert (value.size () != 0);
debug_assert (value.size () != 0);
std::vector<uint8_t> data (static_cast<uint8_t *> (value.data ()), static_cast<uint8_t *> (value.data ()) + value.size ());
std::copy (hash.bytes.begin (), hash.bytes.end (), data.begin () + store.block_successor_offset (transaction, value.size (), type));
store.block_raw_put (transaction, data, type, block_a.previous ());

View file

@ -193,7 +193,7 @@ nano::keypair::keypair (std::string const & prv_a)
{
auto error (prv.data.decode_hex (prv_a));
(void)error;
assert (!error);
debug_assert (!error);
ed25519_publickey (prv.data.bytes.data (), pub.bytes.data ());
}
@ -248,13 +248,13 @@ bool nano::account_info::operator!= (nano::account_info const & other_a) const
size_t nano::account_info::db_size () const
{
assert (reinterpret_cast<const uint8_t *> (this) == reinterpret_cast<const uint8_t *> (&head));
assert (reinterpret_cast<const uint8_t *> (&head) + sizeof (head) == reinterpret_cast<const uint8_t *> (&representative));
assert (reinterpret_cast<const uint8_t *> (&representative) + sizeof (representative) == reinterpret_cast<const uint8_t *> (&open_block));
assert (reinterpret_cast<const uint8_t *> (&open_block) + sizeof (open_block) == reinterpret_cast<const uint8_t *> (&balance));
assert (reinterpret_cast<const uint8_t *> (&balance) + sizeof (balance) == reinterpret_cast<const uint8_t *> (&modified));
assert (reinterpret_cast<const uint8_t *> (&modified) + sizeof (modified) == reinterpret_cast<const uint8_t *> (&block_count));
assert (reinterpret_cast<const uint8_t *> (&block_count) + sizeof (block_count) == reinterpret_cast<const uint8_t *> (&epoch_m));
debug_assert (reinterpret_cast<const uint8_t *> (this) == reinterpret_cast<const uint8_t *> (&head));
debug_assert (reinterpret_cast<const uint8_t *> (&head) + sizeof (head) == reinterpret_cast<const uint8_t *> (&representative));
debug_assert (reinterpret_cast<const uint8_t *> (&representative) + sizeof (representative) == reinterpret_cast<const uint8_t *> (&open_block));
debug_assert (reinterpret_cast<const uint8_t *> (&open_block) + sizeof (open_block) == reinterpret_cast<const uint8_t *> (&balance));
debug_assert (reinterpret_cast<const uint8_t *> (&balance) + sizeof (balance) == reinterpret_cast<const uint8_t *> (&modified));
debug_assert (reinterpret_cast<const uint8_t *> (&modified) + sizeof (modified) == reinterpret_cast<const uint8_t *> (&block_count));
debug_assert (reinterpret_cast<const uint8_t *> (&block_count) + sizeof (block_count) == reinterpret_cast<const uint8_t *> (&epoch_m));
return sizeof (head) + sizeof (representative) + sizeof (open_block) + sizeof (balance) + sizeof (modified) + sizeof (block_count) + sizeof (epoch_m);
}
@ -345,7 +345,7 @@ confirmed (confirmed_a)
void nano::unchecked_info::serialize (nano::stream & stream_a) const
{
assert (block != nullptr);
debug_assert (block != nullptr);
nano::serialize_block (stream_a, *block);
nano::write (stream_a, account.bytes);
nano::write (stream_a, modified);
@ -555,8 +555,8 @@ nano::vote::vote (nano::account const & account_a, nano::raw_key const & prv_a,
sequence (sequence_a),
account (account_a)
{
assert (!blocks_a.empty ());
assert (blocks_a.size () <= 12);
debug_assert (!blocks_a.empty ());
debug_assert (blocks_a.size () <= 12);
blocks.reserve (blocks_a.size ());
std::copy (blocks_a.cbegin (), blocks_a.cend (), std::back_inserter (blocks));
signature = nano::sign_message (prv_a, account_a, hash ());
@ -620,7 +620,7 @@ void nano::vote::serialize (nano::stream & stream_a, nano::block_type type) cons
{
if (block.which ())
{
assert (type == nano::block_type::not_a_block);
debug_assert (type == nano::block_type::not_a_block);
write (stream_a, boost::get<nano::block_hash> (block));
}
else
@ -806,7 +806,7 @@ nano::genesis::genesis ()
{
static nano::network_params network_params;
open = parse_block_from_genesis_data (network_params.ledger.genesis_block);
assert (open != nullptr);
debug_assert (open != nullptr);
}
nano::block_hash nano::genesis::hash () const

View file

@ -1,3 +1,4 @@
#include <nano/lib/utility.hpp>
#include <nano/secure/epoch.hpp>
nano::link const & nano::epochs::link (nano::epoch epoch_a) const
@ -18,13 +19,13 @@ nano::public_key const & nano::epochs::signer (nano::epoch epoch_a) const
nano::epoch nano::epochs::epoch (nano::link const & link_a) const
{
auto existing (std::find_if (epochs_m.begin (), epochs_m.end (), [&link_a](auto const & item_a) { return item_a.second.link == link_a; }));
assert (existing != epochs_m.end ());
debug_assert (existing != epochs_m.end ());
return existing->first;
}
void nano::epochs::add (nano::epoch epoch_a, nano::public_key const & signer_a, nano::link const & link_a)
{
assert (epochs_m.find (epoch_a) == epochs_m.end ());
debug_assert (epochs_m.find (epoch_a) == epochs_m.end ());
epochs_m[epoch_a] = { signer_a, link_a };
}
@ -40,6 +41,6 @@ std::underlying_type_t<nano::epoch> nano::normalized_epoch (nano::epoch epoch_a)
// Currently assumes that the epoch versions in the enum are sequential.
auto start = std::underlying_type_t<nano::epoch> (nano::epoch::epoch_0);
auto end = std::underlying_type_t<nano::epoch> (epoch_a);
assert (end >= start);
debug_assert (end >= start);
return end - start;
}

View file

@ -34,7 +34,7 @@ public:
nano::account_info info;
auto error (ledger.store.account_get (transaction, pending.source, info));
(void)error;
assert (!error);
debug_assert (!error);
ledger.store.pending_del (transaction, key);
ledger.cache.rep_weights.representation_add (info.representative, pending.amount.number ());
nano::account_info new_info (block_a.hashables.previous, info.representative, info.open_block, ledger.balance (transaction, block_a.hashables.previous), nano::seconds_since_epoch (), info.block_count - 1, nano::epoch::epoch_0);
@ -55,7 +55,7 @@ public:
nano::account_info info;
auto error (ledger.store.account_get (transaction, destination_account, info));
(void)error;
assert (!error);
debug_assert (!error);
ledger.cache.rep_weights.representation_add (info.representative, 0 - amount);
nano::account_info new_info (block_a.hashables.previous, info.representative, info.open_block, ledger.balance (transaction, block_a.hashables.previous), nano::seconds_since_epoch (), info.block_count - 1, nano::epoch::epoch_0);
ledger.change_latest (transaction, destination_account, info, new_info);
@ -88,7 +88,7 @@ public:
nano::account_info info;
auto error (ledger.store.account_get (transaction, account, info));
(void)error;
assert (!error);
debug_assert (!error);
auto balance (ledger.balance (transaction, block_a.hashables.previous));
auto block = ledger.store.block_get (transaction, rep_block);
release_assert (block != nullptr);
@ -120,7 +120,7 @@ public:
{
// Move existing representation
auto block (ledger.store.block_get (transaction, rep_block_hash));
assert (block != nullptr);
debug_assert (block != nullptr);
representative = block->representative ();
ledger.cache.rep_weights.representation_add (representative, balance);
}
@ -146,7 +146,7 @@ public:
ledger.stats.inc (nano::stat::type::rollback, nano::stat::detail::receive);
}
assert (!error);
debug_assert (!error);
auto previous_version (ledger.store.block_version (transaction, block_a.hashables.previous));
nano::account_info new_info (block_a.hashables.previous, representative, info.open_block, balance, nano::seconds_since_epoch (), info.block_count - 1, previous_version);
ledger.change_latest (transaction, block_a.hashables.account, info, new_info);
@ -196,7 +196,7 @@ private:
// Returns true if this block which has an epoch link is correctly formed.
bool ledger_processor::validate_epoch_block (nano::state_block const & block_a)
{
assert (ledger.is_epoch_link (block_a.hashables.link));
debug_assert (ledger.is_epoch_link (block_a.hashables.link));
nano::amount prev_balance (0);
if (!block_a.hashables.previous.is_zero ())
{
@ -267,7 +267,7 @@ void ledger_processor::state_block_impl (nano::state_block const & block_a)
}
if (result.code == nano::process_result::progress)
{
assert (!validate_message (block_a.hashables.account, hash, block_a.signature));
debug_assert (!validate_message (block_a.hashables.account, hash, block_a.signature));
result.verified = nano::signature_verification::valid;
result.code = block_a.hashables.account.is_zero () ? nano::process_result::opened_burn_account : nano::process_result::progress; // Is this for the burn account? (Unambiguous)
if (result.code == nano::process_result::progress)
@ -385,7 +385,7 @@ void ledger_processor::epoch_block_impl (nano::state_block const & block_a)
}
if (result.code == nano::process_result::progress)
{
assert (!validate_message (ledger.epoch_signer (block_a.hashables.link), hash, block_a.signature));
debug_assert (!validate_message (ledger.epoch_signer (block_a.hashables.link), hash, block_a.signature));
result.verified = nano::signature_verification::valid_epoch;
result.code = block_a.hashables.account.is_zero () ? nano::process_result::opened_burn_account : nano::process_result::progress; // Is this for the burn account? (Unambiguous)
if (result.code == nano::process_result::progress)
@ -460,8 +460,8 @@ void ledger_processor::change_block (nano::change_block const & block_a)
nano::account_info info;
auto latest_error (ledger.store.account_get (transaction, account, info));
(void)latest_error;
assert (!latest_error);
assert (info.head == block_a.hashables.previous);
debug_assert (!latest_error);
debug_assert (info.head == block_a.hashables.previous);
// Validate block if not verified outside of ledger
if (result.verified != nano::signature_verification::valid)
{
@ -469,7 +469,7 @@ void ledger_processor::change_block (nano::change_block const & block_a)
}
if (result.code == nano::process_result::progress)
{
assert (!validate_message (account, hash, block_a.signature));
debug_assert (!validate_message (account, hash, block_a.signature));
result.verified = nano::signature_verification::valid;
nano::block_sideband sideband (nano::block_type::change, account, 0, info.balance, info.block_count + 1, nano::seconds_since_epoch (), nano::epoch::epoch_0, false, false, false);
ledger.store.block_put (transaction, hash, block_a, sideband);
@ -515,13 +515,13 @@ void ledger_processor::send_block (nano::send_block const & block_a)
}
if (result.code == nano::process_result::progress)
{
assert (!validate_message (account, hash, block_a.signature));
debug_assert (!validate_message (account, hash, block_a.signature));
result.verified = nano::signature_verification::valid;
nano::account_info info;
auto latest_error (ledger.store.account_get (transaction, account, info));
(void)latest_error;
assert (!latest_error);
assert (info.head == block_a.hashables.previous);
debug_assert (!latest_error);
debug_assert (info.head == block_a.hashables.previous);
result.code = info.balance.number () >= block_a.hashables.balance.number () ? nano::process_result::progress : nano::process_result::negative_spend; // Is this trying to spend a negative amount (Malicious)
if (result.code == nano::process_result::progress)
{
@ -571,7 +571,7 @@ void ledger_processor::receive_block (nano::receive_block const & block_a)
}
if (result.code == nano::process_result::progress)
{
assert (!validate_message (account, hash, block_a.signature));
debug_assert (!validate_message (account, hash, block_a.signature));
result.verified = nano::signature_verification::valid;
result.code = ledger.store.source_exists (transaction, block_a.hashables.source) ? nano::process_result::progress : nano::process_result::gap_source; // Have we seen the source block already? (Harmless)
if (result.code == nano::process_result::progress)
@ -593,7 +593,7 @@ void ledger_processor::receive_block (nano::receive_block const & block_a)
nano::account_info source_info;
auto error (ledger.store.account_get (transaction, pending.source, source_info));
(void)error;
assert (!error);
debug_assert (!error);
ledger.store.pending_del (transaction, key);
nano::block_sideband sideband (nano::block_type::receive, account, 0, new_balance, info.block_count + 1, nano::seconds_since_epoch (), nano::epoch::epoch_0, false /* unused */, false /* unused */, false /* unused */);
ledger.store.block_put (transaction, hash, block_a, sideband);
@ -634,7 +634,7 @@ void ledger_processor::open_block (nano::open_block const & block_a)
}
if (result.code == nano::process_result::progress)
{
assert (!validate_message (block_a.hashables.account, hash, block_a.signature));
debug_assert (!validate_message (block_a.hashables.account, hash, block_a.signature));
result.verified = nano::signature_verification::valid;
result.code = ledger.store.source_exists (transaction, block_a.hashables.source) ? nano::process_result::progress : nano::process_result::gap_source; // Have we seen the source block? (Harmless)
if (result.code == nano::process_result::progress)
@ -657,7 +657,7 @@ void ledger_processor::open_block (nano::open_block const & block_a)
nano::account_info source_info;
auto error (ledger.store.account_get (transaction, pending.source, source_info));
(void)error;
assert (!error);
debug_assert (!error);
ledger.store.pending_del (transaction, key);
nano::block_sideband sideband (nano::block_type::open, block_a.hashables.account, 0, pending.amount, 1, nano::seconds_since_epoch (), nano::epoch::epoch_0, false /* unused */, false /* unused */, false /* unused */);
ledger.store.block_put (transaction, hash, block_a, sideband);
@ -754,7 +754,7 @@ nano::uint128_t nano::ledger::account_pending (nano::transaction const & transac
nano::process_return nano::ledger::process (nano::write_transaction const & transaction_a, nano::block const & block_a, nano::signature_verification verification)
{
assert (!nano::work_validate (nano::work_version::work_1, block_a));
debug_assert (!nano::work_validate (nano::work_version::work_1, block_a));
ledger_processor processor (*this, transaction_a, verification);
block_a.visit (processor);
if (processor.result.code == nano::process_result::progress)
@ -767,7 +767,7 @@ nano::process_return nano::ledger::process (nano::write_transaction const & tran
nano::block_hash nano::ledger::representative (nano::transaction const & transaction_a, nano::block_hash const & hash_a)
{
auto result (representative_calculated (transaction_a, hash_a));
assert (result.is_zero () || store.block_exists (transaction_a, result));
debug_assert (result.is_zero () || store.block_exists (transaction_a, result));
return result;
}
@ -846,7 +846,7 @@ nano::block_hash nano::ledger::block_source (nano::transaction const & transacti
* passed in exist in the database. This is because it will try
* to check account balances to determine if it is a send block.
*/
assert (block_a.previous ().is_zero () || store.block_exists (transaction_a, block_a.previous ()));
debug_assert (block_a.previous ().is_zero () || store.block_exists (transaction_a, block_a.previous ()));
// If block_a.source () is nonzero, then we have our source.
// However, universal blocks will always return zero.
@ -883,7 +883,7 @@ nano::uint128_t nano::ledger::weight (nano::account const & account_a)
// Rollback blocks until `block_a' doesn't exist or it tries to penetrate the confirmation height
bool nano::ledger::rollback (nano::write_transaction const & transaction_a, nano::block_hash const & block_a, std::vector<std::shared_ptr<nano::block>> & list_a)
{
assert (store.block_exists (transaction_a, block_a));
debug_assert (store.block_exists (transaction_a, block_a));
auto account_l (account (transaction_a, block_a));
auto block_account_height (store.block_account_height (transaction_a, block_a));
rollback_visitor rollback (transaction_a, *this, list_a);
@ -893,12 +893,12 @@ bool nano::ledger::rollback (nano::write_transaction const & transaction_a, nano
{
nano::confirmation_height_info confirmation_height_info;
auto latest_error = store.confirmation_height_get (transaction_a, account_l, confirmation_height_info);
assert (!latest_error);
debug_assert (!latest_error);
(void)latest_error;
if (block_account_height > confirmation_height_info.height)
{
latest_error = store.account_get (transaction_a, account_l, account_info);
assert (!latest_error);
debug_assert (!latest_error);
auto block (store.block_get (transaction_a, account_info.head));
list_a.push_back (block);
block->visit (rollback);
@ -972,7 +972,7 @@ void nano::ledger::dump_account_chain (nano::account const & account_a)
while (!hash.is_zero ())
{
auto block (store.block_get (transaction, hash));
assert (block != nullptr);
debug_assert (block != nullptr);
std::cerr << hash.to_string () << std::endl;
hash = block->previous ();
}
@ -1045,7 +1045,7 @@ void nano::ledger::change_latest (nano::write_transaction const & transaction_a,
{
if (old_a.head.is_zero () && new_a.open_block == new_a.head)
{
assert (!store.confirmation_height_exists (transaction_a, account_a));
debug_assert (!store.confirmation_height_exists (transaction_a, account_a));
store.confirmation_height_put (transaction_a, account_a, { 0, nano::block_hash (0) });
++cache.account_count;
}
@ -1060,7 +1060,7 @@ void nano::ledger::change_latest (nano::write_transaction const & transaction_a,
{
store.confirmation_height_del (transaction_a, account_a);
store.account_del (transaction_a, account_a);
assert (cache.account_count > 0);
debug_assert (cache.account_count > 0);
--cache.account_count;
}
}
@ -1095,24 +1095,24 @@ std::shared_ptr<nano::block> nano::ledger::successor (nano::transaction const &
{
result = store.block_get (transaction_a, successor);
}
assert (successor.is_zero () || result != nullptr);
debug_assert (successor.is_zero () || result != nullptr);
return result;
}
std::shared_ptr<nano::block> nano::ledger::forked_block (nano::transaction const & transaction_a, nano::block const & block_a)
{
assert (!store.block_exists (transaction_a, block_a.type (), block_a.hash ()));
debug_assert (!store.block_exists (transaction_a, block_a.type (), block_a.hash ()));
auto root (block_a.root ());
assert (store.block_exists (transaction_a, root) || store.account_exists (transaction_a, root));
debug_assert (store.block_exists (transaction_a, root) || store.account_exists (transaction_a, root));
auto result (store.block_get (transaction_a, store.block_successor (transaction_a, root)));
if (result == nullptr)
{
nano::account_info info;
auto error (store.account_get (transaction_a, root, info));
(void)error;
assert (!error);
debug_assert (!error);
result = store.block_get (transaction_a, info.open_block);
assert (result != nullptr);
debug_assert (result != nullptr);
}
return result;
}

View file

@ -64,8 +64,8 @@ void nano::network_filter::clear ()
nano::uint128_t & nano::network_filter::get_element (nano::uint128_t const & hash_a)
{
assert (!mutex.try_lock ());
assert (items.size () > 0);
debug_assert (!mutex.try_lock ());
debug_assert (items.size () > 0);
size_t index (hash_a % items.size ());
return items[index];
}

View file

@ -1,3 +1,4 @@
#include <nano/lib/utility.hpp>
#include <nano/secure/working.hpp>
#include <pwd.h>
@ -8,7 +9,7 @@ namespace nano
boost::filesystem::path app_path ()
{
auto entry (getpwuid (getuid ()));
assert (entry != nullptr);
debug_assert (entry != nullptr);
boost::filesystem::path result (entry->pw_dir);
return result;
}

View file

@ -16,7 +16,7 @@ boost::filesystem::path app_path ()
}
else
{
assert (false);
debug_assert (false);
}
return result;
}

View file

@ -6,7 +6,7 @@
nano::account_info_v1::account_info_v1 (MDB_val const & val_a)
{
assert (val_a.mv_size == sizeof (*this));
debug_assert (val_a.mv_size == sizeof (*this));
static_assert (sizeof (head) + sizeof (rep_block) + sizeof (balance) + sizeof (modified) == sizeof (*this), "Class not packed");
std::copy (reinterpret_cast<uint8_t const *> (val_a.mv_data), reinterpret_cast<uint8_t const *> (val_a.mv_data) + sizeof (*this), reinterpret_cast<uint8_t *> (this));
}
@ -21,7 +21,7 @@ modified (modified_a)
nano::pending_info_v3::pending_info_v3 (MDB_val const & val_a)
{
assert (val_a.mv_size == sizeof (*this));
debug_assert (val_a.mv_size == sizeof (*this));
static_assert (sizeof (source) + sizeof (amount) + sizeof (destination) == sizeof (*this), "Packed class");
std::copy (reinterpret_cast<uint8_t const *> (val_a.mv_data), reinterpret_cast<uint8_t const *> (val_a.mv_data) + sizeof (*this), reinterpret_cast<uint8_t *> (this));
}
@ -68,7 +68,7 @@ bool nano::pending_info_v14::operator== (nano::pending_info_v14 const & other_a)
nano::account_info_v5::account_info_v5 (MDB_val const & val_a)
{
assert (val_a.mv_size == sizeof (*this));
debug_assert (val_a.mv_size == sizeof (*this));
static_assert (sizeof (head) + sizeof (rep_block) + sizeof (open_block) + sizeof (balance) + sizeof (modified) == sizeof (*this), "Class not packed");
std::copy (reinterpret_cast<uint8_t const *> (val_a.mv_data), reinterpret_cast<uint8_t const *> (val_a.mv_data) + sizeof (*this), reinterpret_cast<uint8_t *> (this));
}
@ -95,12 +95,12 @@ epoch (epoch_a)
size_t nano::account_info_v13::db_size () const
{
assert (reinterpret_cast<const uint8_t *> (this) == reinterpret_cast<const uint8_t *> (&head));
assert (reinterpret_cast<const uint8_t *> (&head) + sizeof (head) == reinterpret_cast<const uint8_t *> (&rep_block));
assert (reinterpret_cast<const uint8_t *> (&rep_block) + sizeof (rep_block) == reinterpret_cast<const uint8_t *> (&open_block));
assert (reinterpret_cast<const uint8_t *> (&open_block) + sizeof (open_block) == reinterpret_cast<const uint8_t *> (&balance));
assert (reinterpret_cast<const uint8_t *> (&balance) + sizeof (balance) == reinterpret_cast<const uint8_t *> (&modified));
assert (reinterpret_cast<const uint8_t *> (&modified) + sizeof (modified) == reinterpret_cast<const uint8_t *> (&block_count));
debug_assert (reinterpret_cast<const uint8_t *> (this) == reinterpret_cast<const uint8_t *> (&head));
debug_assert (reinterpret_cast<const uint8_t *> (&head) + sizeof (head) == reinterpret_cast<const uint8_t *> (&rep_block));
debug_assert (reinterpret_cast<const uint8_t *> (&rep_block) + sizeof (rep_block) == reinterpret_cast<const uint8_t *> (&open_block));
debug_assert (reinterpret_cast<const uint8_t *> (&open_block) + sizeof (open_block) == reinterpret_cast<const uint8_t *> (&balance));
debug_assert (reinterpret_cast<const uint8_t *> (&balance) + sizeof (balance) == reinterpret_cast<const uint8_t *> (&modified));
debug_assert (reinterpret_cast<const uint8_t *> (&modified) + sizeof (modified) == reinterpret_cast<const uint8_t *> (&block_count));
return sizeof (head) + sizeof (rep_block) + sizeof (open_block) + sizeof (balance) + sizeof (modified) + sizeof (block_count);
}
@ -118,13 +118,13 @@ epoch (epoch_a)
size_t nano::account_info_v14::db_size () const
{
assert (reinterpret_cast<const uint8_t *> (this) == reinterpret_cast<const uint8_t *> (&head));
assert (reinterpret_cast<const uint8_t *> (&head) + sizeof (head) == reinterpret_cast<const uint8_t *> (&rep_block));
assert (reinterpret_cast<const uint8_t *> (&rep_block) + sizeof (rep_block) == reinterpret_cast<const uint8_t *> (&open_block));
assert (reinterpret_cast<const uint8_t *> (&open_block) + sizeof (open_block) == reinterpret_cast<const uint8_t *> (&balance));
assert (reinterpret_cast<const uint8_t *> (&balance) + sizeof (balance) == reinterpret_cast<const uint8_t *> (&modified));
assert (reinterpret_cast<const uint8_t *> (&modified) + sizeof (modified) == reinterpret_cast<const uint8_t *> (&block_count));
assert (reinterpret_cast<const uint8_t *> (&block_count) + sizeof (block_count) == reinterpret_cast<const uint8_t *> (&confirmation_height));
debug_assert (reinterpret_cast<const uint8_t *> (this) == reinterpret_cast<const uint8_t *> (&head));
debug_assert (reinterpret_cast<const uint8_t *> (&head) + sizeof (head) == reinterpret_cast<const uint8_t *> (&rep_block));
debug_assert (reinterpret_cast<const uint8_t *> (&rep_block) + sizeof (rep_block) == reinterpret_cast<const uint8_t *> (&open_block));
debug_assert (reinterpret_cast<const uint8_t *> (&open_block) + sizeof (open_block) == reinterpret_cast<const uint8_t *> (&balance));
debug_assert (reinterpret_cast<const uint8_t *> (&balance) + sizeof (balance) == reinterpret_cast<const uint8_t *> (&modified));
debug_assert (reinterpret_cast<const uint8_t *> (&modified) + sizeof (modified) == reinterpret_cast<const uint8_t *> (&block_count));
debug_assert (reinterpret_cast<const uint8_t *> (&block_count) + sizeof (block_count) == reinterpret_cast<const uint8_t *> (&confirmation_height));
return sizeof (head) + sizeof (rep_block) + sizeof (open_block) + sizeof (balance) + sizeof (modified) + sizeof (block_count) + sizeof (confirmation_height);
}

View file

@ -309,7 +309,7 @@ TEST (broadcast, world_broadcast_simulate)
case 2:
break;
default:
assert (false);
ASSERT_FALSE (true);
break;
}
}
@ -362,7 +362,7 @@ TEST (broadcast, sqrt_broadcast_simulate)
case 2:
break;
default:
assert (false);
ASSERT_FALSE (true);
break;
}
}