-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
97 changed files
with
5,727 additions
and
1,323 deletions.
There are no files selected for viewing
Submodule libmdbx
updated
from a0ec89 to b7ed67
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
// Copyright (c) 2019, Zano Project | ||
// Copyright (c) 2006-2019, Andrey N. Sabelnikov, www.sabelnikov.net | ||
// All rights reserved. | ||
// | ||
// Redistribution and use in source and binary forms, with or without | ||
// modification, are permitted provided that the following conditions are met: | ||
// * Redistributions of source code must retain the above copyright | ||
// notice, this list of conditions and the following disclaimer. | ||
// * Redistributions in binary form must reproduce the above copyright | ||
// notice, this list of conditions and the following disclaimer in the | ||
// documentation and/or other materials provided with the distribution. | ||
// * Neither the name of the Andrey N. Sabelnikov nor the | ||
// names of its contributors may be used to endorse or promote products | ||
// derived from this software without specific prior written permission. | ||
// | ||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER BE LIABLE FOR ANY | ||
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
// | ||
#pragma once | ||
|
||
#define COMBINE1(X,Y) X##Y // helper macro | ||
#define COMBINE(X,Y) COMBINE1(X,Y) | ||
#define _STR(X) #X | ||
#define STR(X) _STR(X) | ||
|
||
#if defined(_MSC_VER) | ||
#define LOCAL_FUNCTION_DEF__ __FUNCTION__ | ||
#define UNUSED_ATTRIBUTE | ||
#else | ||
#define LOCAL_FUNCTION_DEF__ __FUNCTION__ | ||
#define UNUSED_ATTRIBUTE __attribute__((unused)) | ||
#endif | ||
|
||
#define LOCATION_SS "[" << LOCAL_FUNCTION_DEF__ << ("] @ " __FILE__ ":" STR(__LINE__)) | ||
#define LOCATION_STR (std::string("[") + LOCAL_FUNCTION_DEF__ + "] @ " __FILE__ ":" STR(__LINE__)) | ||
|
||
|
||
// | ||
// Try-catch helpers | ||
// | ||
|
||
#define TRY_ENTRY() try { | ||
#define CATCH_ALL_DO_NOTHING() }catch(...) {} | ||
|
||
#define CATCH_ENTRY_CUSTOM(location, custom_code, return_val) } \ | ||
catch(const std::exception& ex) \ | ||
{ \ | ||
(void)(ex); \ | ||
LOG_ERROR("Exception at [" << location << "], what=" << ex.what()); \ | ||
custom_code; \ | ||
return return_val; \ | ||
} \ | ||
catch(...) \ | ||
{ \ | ||
LOG_ERROR("Exception at [" << location << "], generic exception \"...\""); \ | ||
custom_code; \ | ||
return return_val; \ | ||
} | ||
#define CATCH_ENTRY(location, return_val) CATCH_ENTRY_CUSTOM(location, (void)0, return_val) | ||
#define CATCH_ENTRY2(return_val) CATCH_ENTRY_CUSTOM(LOCATION_SS, (void)0, return_val) | ||
|
||
#define CATCH_ENTRY_L0(location, return_val) CATCH_ENTRY(location, return_val) | ||
#define CATCH_ENTRY_L1(location, return_val) CATCH_ENTRY(location, return_val) | ||
#define CATCH_ENTRY_L2(location, return_val) CATCH_ENTRY(location, return_val) | ||
#define CATCH_ENTRY_L3(location, return_val) CATCH_ENTRY(location, return_val) | ||
#define CATCH_ENTRY_L4(location, return_val) CATCH_ENTRY(location, return_val) | ||
|
||
/// @brief Catches TRY_ENTRY without returning | ||
/// @details Useful within a dtor - but only if nested within another try block | ||
/// (since we can still potentially throw here). See NESTED_*ENTRY() | ||
/// @todo Exception dispatcher class | ||
#define CATCH_ENTRY_NO_RETURN_CUSTOM(location, custom_code) } \ | ||
catch(const std::exception& ex) \ | ||
{ \ | ||
(void)(ex); \ | ||
LOG_ERROR("Exception at [" << location << "], what=" << ex.what()); \ | ||
custom_code; \ | ||
} \ | ||
catch(...) \ | ||
{ \ | ||
LOG_ERROR("Exception at [" << location << "], generic exception \"...\""); \ | ||
custom_code; \ | ||
} | ||
|
||
#define CATCH_ENTRY_NO_RETURN() CATCH_ENTRY_NO_RETURN_CUSTOM(LOCATION_SS, (void)0) | ||
|
||
#define CATCH_ENTRY_WITH_FORWARDING_EXCEPTION() } \ | ||
catch(const std::exception& ex) \ | ||
{ \ | ||
LOG_ERROR("Exception at [" << LOCATION_SS << "], what=" << ex.what()); \ | ||
throw std::runtime_error(std::string("[EXCEPTION FORWARDED]: ") + ex.what()); \ | ||
} \ | ||
catch(...) \ | ||
{ \ | ||
LOG_ERROR("Exception at [" << LOCATION_SS << "], generic unknown exception \"...\""); \ | ||
throw std::runtime_error("[EXCEPTION FORWARDED]"); \ | ||
} | ||
|
||
|
||
|
||
#define NESTED_TRY_ENTRY() try { TRY_ENTRY(); | ||
|
||
#define NESTED_CATCH_ENTRY(location) \ | ||
CATCH_ENTRY_NO_RETURN_CUSTOM(location, {}); \ | ||
} catch (...) {} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
// Copyright (c) 2019, Zano Project | ||
// Copyright (c) 2019, anonimal <[email protected]> | ||
// Copyright (c) 2006-2013, Andrey N. Sabelnikov, www.sabelnikov.net | ||
// All rights reserved. | ||
|
@@ -59,6 +60,7 @@ PUSH_VS_WARNINGS | |
DISABLE_VS_WARNINGS(4100) | ||
|
||
|
||
#include "misc_helpers.h" | ||
#include "static_initializer.h" | ||
#include "string_tools.h" | ||
#include "time_helper.h" | ||
|
@@ -106,21 +108,6 @@ DISABLE_VS_WARNINGS(4100) | |
#endif | ||
|
||
|
||
#define COMBINE1(X,Y) X##Y // helper macro | ||
#define COMBINE(X,Y) COMBINE1(X,Y) | ||
#define _STR(X) #X | ||
#define STR(X) _STR(X) | ||
|
||
#if defined(_MSC_VER) | ||
#define LOCAL_FUNCTION_DEF__ __FUNCTION__ | ||
#define UNUSED_ATTRIBUTE | ||
#else | ||
#define LOCAL_FUNCTION_DEF__ __PRETTY_FUNCTION__ | ||
#define UNUSED_ATTRIBUTE __attribute__((unused)) | ||
#endif | ||
|
||
#define LOCATION_SS "[" << LOCAL_FUNCTION_DEF__ << ("] @ " __FILE__ ":" STR(__LINE__)) | ||
|
||
#if !defined(DISABLE_RELEASE_LOGGING) | ||
#define ENABLE_LOGGING_INTERNAL | ||
#endif | ||
|
@@ -131,28 +118,29 @@ DISABLE_VS_WARNINGS(4100) | |
epee::log_space::log_singletone::enable_channel(ch_name); return true; \ | ||
}); | ||
|
||
|
||
#if defined(ENABLE_LOGGING_INTERNAL) | ||
|
||
#define LOG_PRINT_CHANNEL_NO_PREFIX2(log_channel, log_name, x, y) {if ( y <= epee::log_space::log_singletone::get_log_detalisation_level() && epee::log_space::log_singletone::channel_enabled(log_channel))\ | ||
{std::stringstream ss________; ss________ << x << std::endl; epee::log_space::log_singletone::do_log_message(ss________.str() , y, epee::log_space::console_color_default, false, log_name);}} | ||
{TRY_ENTRY();std::stringstream ss________; ss________ << x << std::endl; epee::log_space::log_singletone::do_log_message(ss________.str() , y, epee::log_space::console_color_default, false, log_name);CATCH_ALL_DO_NOTHING();}} | ||
|
||
#define LOG_PRINT_CHANNEL_NO_PREFIX_NO_POSTFIX2(log_channel, log_name, x, y) {if ( y <= epee::log_space::log_singletone::get_log_detalisation_level() && epee::log_space::log_singletone::channel_enabled(log_channel))\ | ||
{std::stringstream ss________; ss________ << x; epee::log_space::log_singletone::do_log_message(ss________.str(), y, epee::log_space::console_color_default, false, log_name);}} | ||
{TRY_ENTRY();std::stringstream ss________; ss________ << x; epee::log_space::log_singletone::do_log_message(ss________.str(), y, epee::log_space::console_color_default, false, log_name);CATCH_ALL_DO_NOTHING();}} | ||
|
||
#define LOG_PRINT_CHANNEL_NO_POSTFIX2(log_channel, log_name, x, y) {if ( y <= epee::log_space::log_singletone::get_log_detalisation_level() && epee::log_space::log_singletone::channel_enabled(log_channel))\ | ||
{std::stringstream ss________; ss________ << epee::log_space::log_singletone::get_prefix_entry() << x; epee::log_space::log_singletone::do_log_message(ss________.str(), y, epee::log_space::console_color_default, false, log_name);}} | ||
{TRY_ENTRY();std::stringstream ss________; ss________ << epee::log_space::log_singletone::get_prefix_entry() << x; epee::log_space::log_singletone::do_log_message(ss________.str(), y, epee::log_space::console_color_default, false, log_name);CATCH_ALL_DO_NOTHING();}} | ||
|
||
#define LOG_PRINT_CHANNEL2(log_channel, log_name, x, y) {if ( y <= epee::log_space::log_singletone::get_log_detalisation_level() && epee::log_space::log_singletone::channel_enabled(log_channel))\ | ||
{std::stringstream ss________; ss________ << epee::log_space::log_singletone::get_prefix_entry() << x << std::endl;epee::log_space::log_singletone::do_log_message(ss________.str(), y, epee::log_space::console_color_default, false, log_name);}} | ||
{TRY_ENTRY();std::stringstream ss________; ss________ << epee::log_space::log_singletone::get_prefix_entry() << x << std::endl;epee::log_space::log_singletone::do_log_message(ss________.str(), y, epee::log_space::console_color_default, false, log_name);CATCH_ALL_DO_NOTHING();}} | ||
|
||
#define LOG_PRINT_CHANNEL_COLOR2(log_channel, log_name, x, y, color) {if ( y <= epee::log_space::log_singletone::get_log_detalisation_level() && epee::log_space::log_singletone::channel_enabled(log_channel))\ | ||
{std::stringstream ss________; ss________ << epee::log_space::log_singletone::get_prefix_entry() << x << std::endl;epee::log_space::log_singletone::do_log_message(ss________.str(), y, color, false, log_name);}} | ||
{TRY_ENTRY();std::stringstream ss________; ss________ << epee::log_space::log_singletone::get_prefix_entry() << x << std::endl;epee::log_space::log_singletone::do_log_message(ss________.str(), y, color, false, log_name);CATCH_ALL_DO_NOTHING();}} | ||
|
||
#define LOG_PRINT_CHANNEL_2_JORNAL(log_channel, log_name, x, y) {if ( y <= epee::log_space::log_singletone::get_log_detalisation_level() && epee::log_space::log_singletone::channel_enabled(log_channel))\ | ||
{std::stringstream ss________; ss________ << epee::log_space::log_singletone::get_prefix_entry() << x << std::endl;epee::log_space::log_singletone::do_log_message(ss________.str(), y, epee::log_space::console_color_default, true, log_name);}} | ||
{TRY_ENTRY();std::stringstream ss________; ss________ << epee::log_space::log_singletone::get_prefix_entry() << x << std::endl;epee::log_space::log_singletone::do_log_message(ss________.str(), y, epee::log_space::console_color_default, true, log_name);CATCH_ALL_DO_NOTHING();}} | ||
|
||
#define LOG_ERROR2(log_name, x) { \ | ||
std::stringstream ss________; ss________ << epee::log_space::log_singletone::get_prefix_entry() << "[ERROR] Location: " << std::endl << LOCATION_SS << epee::misc_utils::get_callstack() << " Message:" << std::endl << x << std::endl; epee::log_space::log_singletone::do_log_message(ss________.str(), LOG_LEVEL_0, epee::log_space::console_color_red, true, log_name); LOCAL_ASSERT(0); epee::log_space::increase_error_count(LOG_DEFAULT_CHANNEL); } | ||
TRY_ENTRY();std::stringstream ss________; ss________ << epee::log_space::log_singletone::get_prefix_entry() << "[ERROR] Location: " << std::endl << LOCATION_SS << epee::misc_utils::get_callstack() << " Message:" << std::endl << x << std::endl; epee::log_space::log_singletone::do_log_message(ss________.str(), LOG_LEVEL_0, epee::log_space::console_color_red, true, log_name); LOCAL_ASSERT(0); epee::log_space::increase_error_count(LOG_DEFAULT_CHANNEL);CATCH_ALL_DO_NOTHING();} | ||
|
||
#define LOG_FRAME2(log_name, x, y) epee::log_space::log_frame frame(x, y, log_name) | ||
|
||
|
@@ -212,67 +200,6 @@ DISABLE_VS_WARNINGS(4100) | |
|
||
#define ENDL std::endl | ||
|
||
#define TRY_ENTRY() try { | ||
#define CATCH_ENTRY_CUSTOM(location, custom_code, return_val) } \ | ||
catch(const std::exception& ex) \ | ||
{ \ | ||
(void)(ex); \ | ||
LOG_ERROR("Exception at [" << location << "], what=" << ex.what()); \ | ||
custom_code; \ | ||
return return_val; \ | ||
} \ | ||
catch(...) \ | ||
{ \ | ||
LOG_ERROR("Exception at [" << location << "], generic exception \"...\""); \ | ||
custom_code; \ | ||
return return_val; \ | ||
} | ||
#define CATCH_ENTRY(location, return_val) CATCH_ENTRY_CUSTOM(location, (void)0, return_val) | ||
#define CATCH_ENTRY2(return_val) CATCH_ENTRY_CUSTOM(LOCATION_SS, (void)0, return_val) | ||
|
||
#define CATCH_ENTRY_L0(location, return_val) CATCH_ENTRY(location, return_val) | ||
#define CATCH_ENTRY_L1(location, return_val) CATCH_ENTRY(location, return_val) | ||
#define CATCH_ENTRY_L2(location, return_val) CATCH_ENTRY(location, return_val) | ||
#define CATCH_ENTRY_L3(location, return_val) CATCH_ENTRY(location, return_val) | ||
#define CATCH_ENTRY_L4(location, return_val) CATCH_ENTRY(location, return_val) | ||
|
||
/// @brief Catches TRY_ENTRY without returning | ||
/// @details Useful within a dtor - but only if nested within another try block | ||
/// (since we can still potentially throw here). See NESTED_*ENTRY() | ||
/// @todo Exception dispatcher class | ||
#define CATCH_ENTRY_NO_RETURN(location, custom_code) } \ | ||
catch(const std::exception& ex) \ | ||
{ \ | ||
(void)(ex); \ | ||
LOG_ERROR("Exception at [" << location << "], what=" << ex.what()); \ | ||
custom_code; \ | ||
} \ | ||
catch(...) \ | ||
{ \ | ||
LOG_ERROR("Exception at [" << location << "], generic exception \"...\""); \ | ||
custom_code; \ | ||
} | ||
|
||
|
||
#define CATCH_ENTRY_WITH_FORWARDING_EXCEPTION() } \ | ||
catch(const std::exception& ex) \ | ||
{ \ | ||
LOG_ERROR("Exception at [" << LOCATION_SS << "], what=" << ex.what()); \ | ||
throw std::runtime_error(std::string("[EXCEPTION FORWARDED]: ") + ex.what()); \ | ||
} \ | ||
catch(...) \ | ||
{ \ | ||
LOG_ERROR("Exception at [" << LOCATION_SS << "], generic unknown exception \"...\""); \ | ||
throw std::runtime_error("[EXCEPTION FORWARDED]"); \ | ||
} | ||
|
||
|
||
|
||
#define NESTED_TRY_ENTRY() try { TRY_ENTRY(); | ||
|
||
#define NESTED_CATCH_ENTRY(location) \ | ||
CATCH_ENTRY_NO_RETURN(location, {}); \ | ||
} catch (...) {} | ||
|
||
#define ASSERT_MES_AND_THROW(message) {LOG_ERROR(message); std::stringstream ss; ss << message; throw std::runtime_error(ss.str());} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright (c) 2006-2019, Andrey N. Sabelnikov, www.sabelnikov.net | ||
// All rights reserved. | ||
// | ||
// Redistribution and use in source and binary forms, with or without | ||
// modification, are permitted provided that the following conditions are met: | ||
// * Redistributions of source code must retain the above copyright | ||
// notice, this list of conditions and the following disclaimer. | ||
// * Redistributions in binary form must reproduce the above copyright | ||
// notice, this list of conditions and the following disclaimer in the | ||
// documentation and/or other materials provided with the distribution. | ||
// * Neither the name of the Andrey N. Sabelnikov nor the | ||
// names of its contributors may be used to endorse or promote products | ||
// derived from this software without specific prior written permission. | ||
// | ||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER BE LIABLE FOR ANY | ||
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
// | ||
|
||
#pragma once | ||
#include "keyvalue_serialization.h" | ||
namespace epee | ||
{ | ||
|
||
struct hexemizer | ||
{ | ||
std::string blob; | ||
BEGIN_KV_SERIALIZE_MAP() | ||
KV_SERIALIZE_BLOB_AS_HEX_STRING(blob) | ||
END_KV_SERIALIZE_MAP() | ||
}; | ||
|
||
|
||
} |
Oops, something went wrong.