From eb8230d50b6735f3a7881579c0500254c6e3d112 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rio=20Silva?= Date: Wed, 24 Oct 2018 20:43:19 +0100 Subject: [PATCH 01/16] add generic_index signals --- include/chainbase/chainbase.hpp | 38 +++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/include/chainbase/chainbase.hpp b/include/chainbase/chainbase.hpp index 7ce93bc..f7b1c5a 100644 --- a/include/chainbase/chainbase.hpp +++ b/include/chainbase/chainbase.hpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -57,6 +58,32 @@ namespace chainbase { constexpr char _db_dirty_flag_string[] = "db_dirty_flag"; + /** + * Plugins / observers listening to signals emited (such as accepted_transaction) might trigger + * errors and throw exceptions. Unless those exceptions are caught it could impact consensus and/or + * cause a node to fork. + * + * If it is ever desirable to let a signal handler bubble an exception out of this method + * a full audit of its uses needs to be undertaken. + * + */ + template + void emit( const Signal& s, Arg&& a ) { + try { + s(std::forward(a)); + } catch (boost::interprocess::bad_alloc& e) { + wlog( "bad alloc" ); + throw e; + } catch ( controller_emit_signal_exception& e ) { + wlog( "${details}", ("details", e.to_detail_string()) ); + throw e; + } catch ( fc::exception& e ) { + wlog( "${details}", ("details", e.to_detail_string()) ); + } catch ( ... ) { + wlog( "signal handler threw exception" ); + } + } + struct strcmp_less { bool operator()( const shared_string& a, const shared_string& b )const @@ -191,6 +218,10 @@ namespace chainbase { typedef bip::allocator< generic_index, segment_manager_type > allocator_type; typedef undo_state< value_type > undo_state_type; + signal applied_emplace; + signal applied_modify; + signal applied_remove; + generic_index( allocator a ) :_stack(a),_indices( a ),_size_of_value_type( sizeof(typename MultiIndexType::node_type) ),_size_of_this(sizeof(*this)){} @@ -220,6 +251,9 @@ namespace chainbase { ++_next_id; on_create( *insert_result.first ); + + emit(applied_emplace, *insert_result.first ); + return *insert_result.first; } @@ -228,11 +262,15 @@ namespace chainbase { on_modify( obj ); auto ok = _indices.modify( _indices.iterator_to( obj ), m ); if( !ok ) BOOST_THROW_EXCEPTION( std::logic_error( "Could not modify object, most likely a uniqueness constraint was violated" ) ); + + emit(applied_modify, obj ); } void remove( const value_type& obj ) { on_remove( obj ); _indices.erase( _indices.iterator_to( obj ) ); + + emit(applied_remove, obj ); } template From 78e95055a3c9970c19b139e9c8d6bb9eb4164a63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rio=20Silva?= Date: Wed, 24 Oct 2018 22:28:44 +0100 Subject: [PATCH 02/16] Update chainbase.hpp --- include/chainbase/chainbase.hpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/include/chainbase/chainbase.hpp b/include/chainbase/chainbase.hpp index f7b1c5a..e1609b0 100644 --- a/include/chainbase/chainbase.hpp +++ b/include/chainbase/chainbase.hpp @@ -47,6 +47,7 @@ namespace chainbase { namespace bfs = boost::filesystem; using std::unique_ptr; using std::vector; + using boost::signals2::signal; template using allocator = bip::allocator; @@ -72,15 +73,10 @@ namespace chainbase { try { s(std::forward(a)); } catch (boost::interprocess::bad_alloc& e) { - wlog( "bad alloc" ); + BOOST_THROW_EXCEPTION( std::logic_error("bad alloc") ); throw e; - } catch ( controller_emit_signal_exception& e ) { - wlog( "${details}", ("details", e.to_detail_string()) ); - throw e; - } catch ( fc::exception& e ) { - wlog( "${details}", ("details", e.to_detail_string()) ); } catch ( ... ) { - wlog( "signal handler threw exception" ); + BOOST_THROW_EXCEPTION( std::logic_error("signal handler threw exception") ); } } From fa931bd8ef13f3623ffc1476712b0329a2fe2425 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rio=20Silva?= Date: Thu, 25 Oct 2018 00:25:17 +0100 Subject: [PATCH 03/16] Update chainbase.hpp --- include/chainbase/chainbase.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/chainbase/chainbase.hpp b/include/chainbase/chainbase.hpp index e1609b0..26246f1 100644 --- a/include/chainbase/chainbase.hpp +++ b/include/chainbase/chainbase.hpp @@ -13,6 +13,10 @@ #include +#pragma push_macro("N") +#undef N + + #include #include #include @@ -21,6 +25,8 @@ #include #include +#pragma pop_macro("N") + #include #include #include From 29cd7668d700ba3fcc5c76fc1df20bf4bdeab62f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rio=20Silva?= Date: Fri, 26 Oct 2018 01:54:33 +0100 Subject: [PATCH 04/16] Update chainbase.hpp --- include/chainbase/chainbase.hpp | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/include/chainbase/chainbase.hpp b/include/chainbase/chainbase.hpp index 26246f1..f402923 100644 --- a/include/chainbase/chainbase.hpp +++ b/include/chainbase/chainbase.hpp @@ -75,7 +75,7 @@ namespace chainbase { * */ template - void emit( const Signal& s, Arg&& a ) { + void emit(const Signal& s, Arg&& a ) { try { s(std::forward(a)); } catch (boost::interprocess::bad_alloc& e) { @@ -220,10 +220,6 @@ namespace chainbase { typedef bip::allocator< generic_index, segment_manager_type > allocator_type; typedef undo_state< value_type > undo_state_type; - signal applied_emplace; - signal applied_modify; - signal applied_remove; - generic_index( allocator a ) :_stack(a),_indices( a ),_size_of_value_type( sizeof(typename MultiIndexType::node_type) ),_size_of_this(sizeof(*this)){} @@ -541,6 +537,21 @@ namespace chainbase { const auto& stack()const { return _stack; } + template + void connect_emplace(Connector c ) const { + applied_emplace.connect(std::forward(c)); + } + + template + void connect_modify(Connector c ) const { + applied_modify.connect(std::forward(c)); + } + + template + void connect_remove(Connector c ) const { + applied_remove.connect(std::forward(c)); + } + private: bool enabled()const { return _stack.size(); } @@ -588,6 +599,10 @@ namespace chainbase { head.new_ids.insert( v.id ); } + signal applied_emplace; + signal applied_modify; + signal applied_remove; + boost::interprocess::deque< undo_state_type, allocator > _stack; /** From d6978b9e7c7f11381a5fe35c8ba99e579dc5a8dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rio=20Silva?= Date: Fri, 26 Oct 2018 15:52:13 +0100 Subject: [PATCH 05/16] Update chainbase.hpp --- include/chainbase/chainbase.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/chainbase/chainbase.hpp b/include/chainbase/chainbase.hpp index f402923..1d719e6 100644 --- a/include/chainbase/chainbase.hpp +++ b/include/chainbase/chainbase.hpp @@ -539,17 +539,17 @@ namespace chainbase { template void connect_emplace(Connector c ) const { - applied_emplace.connect(std::forward(c)); + applied_emplace.connect(c); } template void connect_modify(Connector c ) const { - applied_modify.connect(std::forward(c)); + applied_modify.connect(c); } template void connect_remove(Connector c ) const { - applied_remove.connect(std::forward(c)); + applied_remove.connect(c); } private: From f88cc3c71cc807de98f296dcc26cef64add316a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rio=20Silva?= Date: Sat, 27 Oct 2018 02:07:25 +0100 Subject: [PATCH 06/16] fix usage of signals to function callback --- include/chainbase/chainbase.hpp | 36 +++++++++------------------------ 1 file changed, 10 insertions(+), 26 deletions(-) diff --git a/include/chainbase/chainbase.hpp b/include/chainbase/chainbase.hpp index 1d719e6..8eeaadd 100644 --- a/include/chainbase/chainbase.hpp +++ b/include/chainbase/chainbase.hpp @@ -13,16 +13,16 @@ #include -#pragma push_macro("N") -#undef N - - #include #include #include #include #include #include + +#pragma push_macro("N") +#undef N + #include #pragma pop_macro("N") @@ -75,9 +75,9 @@ namespace chainbase { * */ template - void emit(const Signal& s, Arg&& a ) { + void emit(const Signal s, Arg&& a ) { try { - s(std::forward(a)); + if(!s.empty()) s(std::forward(a)); } catch (boost::interprocess::bad_alloc& e) { BOOST_THROW_EXCEPTION( std::logic_error("bad alloc") ); throw e; @@ -219,6 +219,7 @@ namespace chainbase { typedef typename index_type::value_type value_type; typedef bip::allocator< generic_index, segment_manager_type > allocator_type; typedef undo_state< value_type > undo_state_type; + typedef boost::function signal_type; generic_index( allocator a ) :_stack(a),_indices( a ),_size_of_value_type( sizeof(typename MultiIndexType::node_type) ),_size_of_this(sizeof(*this)){} @@ -535,22 +536,9 @@ namespace chainbase { return {begin, end}; } - const auto& stack()const { return _stack; } - - template - void connect_emplace(Connector c ) const { - applied_emplace.connect(c); - } - - template - void connect_modify(Connector c ) const { - applied_modify.connect(c); - } - - template - void connect_remove(Connector c ) const { - applied_remove.connect(c); - } + mutable signal_type applied_emplace; + mutable signal_type applied_modify; + mutable signal_type applied_remove; private: bool enabled()const { return _stack.size(); } @@ -599,10 +587,6 @@ namespace chainbase { head.new_ids.insert( v.id ); } - signal applied_emplace; - signal applied_modify; - signal applied_remove; - boost::interprocess::deque< undo_state_type, allocator > _stack; /** From 816d36675f4ac93e58b66f1e7dca8d4d710ab3a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rio=20Silva?= Date: Sun, 28 Oct 2018 01:40:00 +0000 Subject: [PATCH 07/16] fix to remove --- include/chainbase/chainbase.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/chainbase/chainbase.hpp b/include/chainbase/chainbase.hpp index 8eeaadd..c1b6e32 100644 --- a/include/chainbase/chainbase.hpp +++ b/include/chainbase/chainbase.hpp @@ -267,9 +267,10 @@ namespace chainbase { void remove( const value_type& obj ) { on_remove( obj ); - _indices.erase( _indices.iterator_to( obj ) ); emit(applied_remove, obj ); + + _indices.erase( _indices.iterator_to( obj ) ); } template From f3f3e57806cdc60b7545ac37e96af42b02740ffe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rio=20Silva?= Date: Mon, 29 Oct 2018 11:04:15 +0000 Subject: [PATCH 08/16] Update chainbase.hpp --- include/chainbase/chainbase.hpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/chainbase/chainbase.hpp b/include/chainbase/chainbase.hpp index c1b6e32..539f66d 100644 --- a/include/chainbase/chainbase.hpp +++ b/include/chainbase/chainbase.hpp @@ -376,6 +376,8 @@ namespace chainbase { _stack.pop_back(); --_revision; + + emit(applied_undo, _revision ); } /** @@ -485,6 +487,8 @@ namespace chainbase { _stack.pop_back(); --_revision; + + emit(applied_squash, _revision ); } /** @@ -496,6 +500,8 @@ namespace chainbase { { _stack.pop_front(); } + + emit(applied_commit, revision ); } /** @@ -540,6 +546,9 @@ namespace chainbase { mutable signal_type applied_emplace; mutable signal_type applied_modify; mutable signal_type applied_remove; + mutable signal_type applied_undo; + mutable signal_type applied_squash; + mutable signal_type applied_commit; private: bool enabled()const { return _stack.size(); } From d6e239aa66f535d9b3b4e7e9b8e6ca92621e06d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rio=20Silva?= Date: Mon, 29 Oct 2018 11:08:12 +0000 Subject: [PATCH 09/16] Update chainbase.hpp --- include/chainbase/chainbase.hpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/include/chainbase/chainbase.hpp b/include/chainbase/chainbase.hpp index 539f66d..ee24f57 100644 --- a/include/chainbase/chainbase.hpp +++ b/include/chainbase/chainbase.hpp @@ -219,7 +219,8 @@ namespace chainbase { typedef typename index_type::value_type value_type; typedef bip::allocator< generic_index, segment_manager_type > allocator_type; typedef undo_state< value_type > undo_state_type; - typedef boost::function signal_type; + typedef boost::function signal_op_type; + typedef boost::function signal_rev_type; generic_index( allocator a ) :_stack(a),_indices( a ),_size_of_value_type( sizeof(typename MultiIndexType::node_type) ),_size_of_this(sizeof(*this)){} @@ -543,12 +544,12 @@ namespace chainbase { return {begin, end}; } - mutable signal_type applied_emplace; - mutable signal_type applied_modify; - mutable signal_type applied_remove; - mutable signal_type applied_undo; - mutable signal_type applied_squash; - mutable signal_type applied_commit; + mutable signal_op_type applied_emplace; + mutable signal_op_type applied_modify; + mutable signal_op_type applied_remove; + mutable signal_rev_type applied_undo; + mutable signal_rev_type applied_squash; + mutable signal_rev_type applied_commit; private: bool enabled()const { return _stack.size(); } From 8529e29856c23aee76a4092a404781371cd5226e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rio=20Silva?= Date: Mon, 29 Oct 2018 11:17:37 +0000 Subject: [PATCH 10/16] Update chainbase.hpp --- include/chainbase/chainbase.hpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/include/chainbase/chainbase.hpp b/include/chainbase/chainbase.hpp index ee24f57..8573e4e 100644 --- a/include/chainbase/chainbase.hpp +++ b/include/chainbase/chainbase.hpp @@ -20,13 +20,6 @@ #include #include -#pragma push_macro("N") -#undef N - -#include - -#pragma pop_macro("N") - #include #include #include From 2e29ae44d1a43dc5eba15f123b40678cf2b4a896 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rio=20Silva?= Date: Mon, 29 Oct 2018 23:28:06 +0000 Subject: [PATCH 11/16] fixes to chainbase --- include/chainbase/chainbase.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/include/chainbase/chainbase.hpp b/include/chainbase/chainbase.hpp index 8573e4e..b0a535f 100644 --- a/include/chainbase/chainbase.hpp +++ b/include/chainbase/chainbase.hpp @@ -46,7 +46,6 @@ namespace chainbase { namespace bfs = boost::filesystem; using std::unique_ptr; using std::vector; - using boost::signals2::signal; template using allocator = bip::allocator; From 2412f00982af0227abfd35810f2131e24c53d459 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rio=20Silva?= Date: Thu, 1 Nov 2018 01:46:01 +0000 Subject: [PATCH 12/16] changes to chainbase --- include/chainbase/chainbase.hpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/include/chainbase/chainbase.hpp b/include/chainbase/chainbase.hpp index b0a535f..1ef4155 100644 --- a/include/chainbase/chainbase.hpp +++ b/include/chainbase/chainbase.hpp @@ -347,30 +347,40 @@ namespace chainbase { void undo() { if( !enabled() ) return; + emit(applied_undo, _revision ); + const auto& head = _stack.back(); for( auto& item : head.old_values ) { - auto ok = _indices.modify( _indices.find( item.second.id ), [&]( value_type& v ) { + emit(applied_modify, item.second); + + auto ok = _indices.modify(_indices.find( item.second.id ), [&]( value_type& v ) { v = std::move( item.second ); }); + if( !ok ) BOOST_THROW_EXCEPTION( std::logic_error( "Could not modify object, most likely a uniqueness constraint was violated" ) ); } for( auto id : head.new_ids ) { - _indices.erase( _indices.find( id ) ); + const auto& itr = _indices.find( id ); + + if( itr != _indices.end()) + emit(applied_remove, *itr); + + _indices.erase( itr ); } _next_id = head.old_next_id; for( auto& item : head.removed_values ) { + emit(applied_emplace, item.second); + bool ok = _indices.emplace( std::move( item.second ) ).second; if( !ok ) BOOST_THROW_EXCEPTION( std::logic_error( "Could not restore object, most likely a uniqueness constraint was violated" ) ); } _stack.pop_back(); --_revision; - - emit(applied_undo, _revision ); } /** @@ -480,8 +490,6 @@ namespace chainbase { _stack.pop_back(); --_revision; - - emit(applied_squash, _revision ); } /** @@ -540,7 +548,6 @@ namespace chainbase { mutable signal_op_type applied_modify; mutable signal_op_type applied_remove; mutable signal_rev_type applied_undo; - mutable signal_rev_type applied_squash; mutable signal_rev_type applied_commit; private: From cda29335fd622d7a5d1fd3ee86f9dcd083d0ab95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rio=20Silva?= Date: Mon, 5 Nov 2018 17:52:22 +0000 Subject: [PATCH 13/16] Update chainbase.hpp --- include/chainbase/chainbase.hpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/include/chainbase/chainbase.hpp b/include/chainbase/chainbase.hpp index 1ef4155..8f08d86 100644 --- a/include/chainbase/chainbase.hpp +++ b/include/chainbase/chainbase.hpp @@ -501,8 +501,6 @@ namespace chainbase { { _stack.pop_front(); } - - emit(applied_commit, revision ); } /** @@ -548,7 +546,6 @@ namespace chainbase { mutable signal_op_type applied_modify; mutable signal_op_type applied_remove; mutable signal_rev_type applied_undo; - mutable signal_rev_type applied_commit; private: bool enabled()const { return _stack.size(); } From e52d821c73d33279be3a3733374115aff78eb338 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rio=20Silva?= Date: Wed, 14 Nov 2018 22:44:39 +0000 Subject: [PATCH 14/16] implement signals to generic_index events --- include/chainbase/chainbase.hpp | 59 +++++++++++++++++++++------------ 1 file changed, 37 insertions(+), 22 deletions(-) diff --git a/include/chainbase/chainbase.hpp b/include/chainbase/chainbase.hpp index 8f08d86..a2967c8 100644 --- a/include/chainbase/chainbase.hpp +++ b/include/chainbase/chainbase.hpp @@ -20,6 +20,13 @@ #include #include +#pragma push_macro("N") +#undef N + +#include + +#pragma pop_macro("N") + #include #include #include @@ -46,6 +53,7 @@ namespace chainbase { namespace bfs = boost::filesystem; using std::unique_ptr; using std::vector; + using boost::signals2::signal; template using allocator = bip::allocator; @@ -58,23 +66,29 @@ namespace chainbase { constexpr char _db_dirty_flag_string[] = "db_dirty_flag"; /** - * Plugins / observers listening to signals emited (such as accepted_transaction) might trigger - * errors and throw exceptions. Unless those exceptions are caught it could impact consensus and/or - * cause a node to fork. - * - * If it is ever desirable to let a signal handler bubble an exception out of this method - * a full audit of its uses needs to be undertaken. - * - */ - template - void emit(const Signal s, Arg&& a ) { - try { - if(!s.empty()) s(std::forward(a)); - } catch (boost::interprocess::bad_alloc& e) { - BOOST_THROW_EXCEPTION( std::logic_error("bad alloc") ); + * Plugins / observers listening to signals emited (such as accepted_transaction) might trigger + * errors and throw exceptions. Unless those exceptions are caught it could impact consensus and/or + * cause a node to fork. + * + * If it is ever desirable to let a signal handler bubble an exception out of this method + * a full audit of its uses needs to be undertaken. + * + */ + template + void emit(const Signal &s, Arg &&a) + { + try + { + s(std::forward(a)); + } + catch (boost::interprocess::bad_alloc &e) + { + std::cerr << "bad alloc"; throw e; - } catch ( ... ) { - BOOST_THROW_EXCEPTION( std::logic_error("signal handler threw exception") ); + } + catch (...) + { + std::cerr << "signal handler threw exception"; } } @@ -211,8 +225,8 @@ namespace chainbase { typedef typename index_type::value_type value_type; typedef bip::allocator< generic_index, segment_manager_type > allocator_type; typedef undo_state< value_type > undo_state_type; - typedef boost::function signal_op_type; - typedef boost::function signal_rev_type; + typedef signal signal_op_type; + typedef signal signal_rev_type; generic_index( allocator a ) :_stack(a),_indices( a ),_size_of_value_type( sizeof(typename MultiIndexType::node_type) ),_size_of_this(sizeof(*this)){} @@ -542,10 +556,11 @@ namespace chainbase { return {begin, end}; } - mutable signal_op_type applied_emplace; - mutable signal_op_type applied_modify; - mutable signal_op_type applied_remove; - mutable signal_rev_type applied_undo; + const auto &stack() const { return _stack; } + mutable signal_op_type applied_emplace; + mutable signal_op_type applied_modify; + mutable signal_op_type applied_remove; + mutable signal_rev_type applied_undo; private: bool enabled()const { return _stack.size(); } From f80444098476ea21ec414e8e03b57b2506db0060 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Berr=C3=ADos?= Date: Wed, 14 Nov 2018 17:07:25 -0800 Subject: [PATCH 15/16] Revert unnecessary modification --- include/chainbase/chainbase.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/chainbase/chainbase.hpp b/include/chainbase/chainbase.hpp index a2967c8..9459e6d 100644 --- a/include/chainbase/chainbase.hpp +++ b/include/chainbase/chainbase.hpp @@ -556,7 +556,7 @@ namespace chainbase { return {begin, end}; } - const auto &stack() const { return _stack; } + const auto& stack()const { return _stack; } mutable signal_op_type applied_emplace; mutable signal_op_type applied_modify; mutable signal_op_type applied_remove; From 1eafa0874025abd7c3e5eebb2c8f0d559c66fee9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rio=20Silva?= Date: Mon, 26 Nov 2018 23:43:06 +0000 Subject: [PATCH 16/16] change location for emit function --- include/chainbase/chainbase.hpp | 54 ++++++++++++++++----------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/include/chainbase/chainbase.hpp b/include/chainbase/chainbase.hpp index a2967c8..6ea2c5f 100644 --- a/include/chainbase/chainbase.hpp +++ b/include/chainbase/chainbase.hpp @@ -65,33 +65,6 @@ namespace chainbase { constexpr char _db_dirty_flag_string[] = "db_dirty_flag"; - /** - * Plugins / observers listening to signals emited (such as accepted_transaction) might trigger - * errors and throw exceptions. Unless those exceptions are caught it could impact consensus and/or - * cause a node to fork. - * - * If it is ever desirable to let a signal handler bubble an exception out of this method - * a full audit of its uses needs to be undertaken. - * - */ - template - void emit(const Signal &s, Arg &&a) - { - try - { - s(std::forward(a)); - } - catch (boost::interprocess::bad_alloc &e) - { - std::cerr << "bad alloc"; - throw e; - } - catch (...) - { - std::cerr << "signal handler threw exception"; - } - } - struct strcmp_less { bool operator()( const shared_string& a, const shared_string& b )const @@ -556,6 +529,33 @@ namespace chainbase { return {begin, end}; } + /** + * Plugins / observers listening to signals emited (such as accepted_transaction) might trigger + * errors and throw exceptions. Unless those exceptions are caught it could impact consensus and/or + * cause a node to fork. + * + * If it is ever desirable to let a signal handler bubble an exception out of this method + * a full audit of its uses needs to be undertaken. + * + */ + template + void emit(const Signal &s, Arg &&a) + { + try + { + s(std::forward(a)); + } + catch (boost::interprocess::bad_alloc &e) + { + std::cerr << "bad alloc"; + throw e; + } + catch (...) + { + std::cerr << "signal handler threw exception"; + } + } + const auto &stack() const { return _stack; } mutable signal_op_type applied_emplace; mutable signal_op_type applied_modify;