diff --git a/libraries/app/application.cpp b/libraries/app/application.cpp index 9dcbda94..a3c73eee 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -334,7 +334,7 @@ namespace detail { reset_p2p_node(_data_dir); reset_websocket_server(); reset_websocket_tls_server(); - } FC_CAPTURE_AND_RETHROW() } + } FC_LOG_AND_RETHROW() } optional< api_access_info > get_api_access_info(const string& username)const { @@ -859,7 +859,15 @@ void application::initialize(const fc::path& data_dir, const boost::program_opti void application::startup() { + try { my->startup(); + } catch ( const fc::exception& e ) { + elog( "${e}", ("e",e.to_detail_string()) ); + throw; + } catch ( ... ) { + elog( "unexpected exception" ); + throw; + } } std::shared_ptr application::get_plugin(const string& name) const diff --git a/libraries/chain/db_block.cpp b/libraries/chain/db_block.cpp index dff4f65d..0d83b6e9 100644 --- a/libraries/chain/db_block.cpp +++ b/libraries/chain/db_block.cpp @@ -245,7 +245,7 @@ processed_transaction database::validate_transaction( const signed_transaction& } processed_transaction database::push_proposal(const proposal_object& proposal) -{ +{ try { transaction_evaluation_state eval_state(this); eval_state._is_proposed_trx = true; @@ -253,15 +253,20 @@ processed_transaction database::push_proposal(const proposal_object& proposal) processed_transaction ptrx(proposal.proposed_transaction); eval_state._trx = &ptrx; - auto session = _undo_db.start_undo_session(); - for( auto& op : proposal.proposed_transaction.operations ) - eval_state.operation_results.emplace_back(apply_operation(eval_state, op)); - remove(proposal); - session.merge(); + try { + auto session = _undo_db.start_undo_session(true); + for( auto& op : proposal.proposed_transaction.operations ) + eval_state.operation_results.emplace_back(apply_operation(eval_state, op)); + remove(proposal); + session.merge(); + } catch ( const fc::exception& e ) { + elog( "e", ("e",e.to_detail_string() ) ); + throw; + } ptrx.operation_results = std::move(eval_state.operation_results); return ptrx; -} +} FC_CAPTURE_AND_RETHROW( (proposal) ) } signed_block database::generate_block( fc::time_point_sec when, diff --git a/libraries/chain/db_management.cpp b/libraries/chain/db_management.cpp index 3ec802c3..6d26984d 100644 --- a/libraries/chain/db_management.cpp +++ b/libraries/chain/db_management.cpp @@ -165,7 +165,7 @@ void database::open( //idump((head_block_id())(head_block_num())); } - FC_CAPTURE_AND_RETHROW( (data_dir) ) + FC_CAPTURE_LOG_AND_RETHROW( (data_dir) ) } void database::close(uint32_t blocks_to_rewind) diff --git a/libraries/chain/get_config.cpp b/libraries/chain/get_config.cpp index 1d81ecfb..8f72bf28 100644 --- a/libraries/chain/get_config.cpp +++ b/libraries/chain/get_config.cpp @@ -32,7 +32,6 @@ fc::variant_object get_config() result[ "GRAPHENE_MAX_ACCOUNT_NAME_LENGTH" ] = GRAPHENE_MAX_ACCOUNT_NAME_LENGTH; result[ "GRAPHENE_MIN_ASSET_SYMBOL_LENGTH" ] = GRAPHENE_MIN_ASSET_SYMBOL_LENGTH; result[ "GRAPHENE_MAX_ASSET_SYMBOL_LENGTH" ] = GRAPHENE_MAX_ASSET_SYMBOL_LENGTH; - result[ "GRAPHENE_MAX_ASSET_NAME_LENGTH" ] = GRAPHENE_MAX_ASSET_NAME_LENGTH; result[ "GRAPHENE_MAX_SHARE_SUPPLY" ] = GRAPHENE_MAX_SHARE_SUPPLY; result[ "GRAPHENE_MAX_PAY_RATE" ] = GRAPHENE_MAX_PAY_RATE; result[ "GRAPHENE_MAX_SIG_CHECK_DEPTH" ] = GRAPHENE_MAX_SIG_CHECK_DEPTH; diff --git a/libraries/chain/include/graphene/chain/config.hpp b/libraries/chain/include/graphene/chain/config.hpp index a02ffd54..a16e6705 100644 --- a/libraries/chain/include/graphene/chain/config.hpp +++ b/libraries/chain/include/graphene/chain/config.hpp @@ -26,8 +26,6 @@ #define GRAPHENE_MIN_ASSET_SYMBOL_LENGTH 3 #define GRAPHENE_MAX_ASSET_SYMBOL_LENGTH 16 -#define GRAPHENE_MAX_ASSET_NAME_LENGTH 127 - #define GRAPHENE_MAX_SHARE_SUPPLY int64_t(1000000000000000ll) #define GRAPHENE_MAX_PAY_RATE 10000 /* 100% */ #define GRAPHENE_MAX_SIG_CHECK_DEPTH 2 diff --git a/libraries/db/include/graphene/db/undo_database.hpp b/libraries/db/include/graphene/db/undo_database.hpp index 4cf206ee..ab87998d 100644 --- a/libraries/db/include/graphene/db/undo_database.hpp +++ b/libraries/db/include/graphene/db/undo_database.hpp @@ -62,32 +62,34 @@ namespace graphene { namespace db { elog( "${e}", ("e",e.to_detail_string() ) ); throw; // maybe crash.. } + if( _disable_on_exit ) _db.disable(); } void commit() { _apply_undo = false; _db.commit(); } void undo() { if( _apply_undo ) _db.undo(); _apply_undo = false; } void merge() { if( _apply_undo ) _db.merge(); _apply_undo = false; } session& operator = ( session&& mv ) - { + { try { if( this == &mv ) return *this; if( _apply_undo ) _db.undo(); _apply_undo = mv._apply_undo; mv._apply_undo = false; return *this; - } + } FC_CAPTURE_AND_RETHROW() } private: friend class undo_database; - session(undo_database& db): _db(db) {} + session(undo_database& db, bool disable_on_exit = false): _db(db),_disable_on_exit(disable_on_exit) {} undo_database& _db; bool _apply_undo = true; + bool _disable_on_exit = false; }; void disable(); void enable(); bool enabled()const { return !_disabled; } - session start_undo_session(); + session start_undo_session( bool force_enable = false ); /** * This should be called just after an object is created */ diff --git a/libraries/db/undo_database.cpp b/libraries/db/undo_database.cpp index 9534f683..945163fe 100644 --- a/libraries/db/undo_database.cpp +++ b/libraries/db/undo_database.cpp @@ -24,16 +24,19 @@ namespace graphene { namespace db { void undo_database::enable() { _disabled = false; } void undo_database::disable() { _disabled = true; } -undo_database::session undo_database::start_undo_session() +undo_database::session undo_database::start_undo_session( bool force_enable ) { - if( _disabled ) return session(*this); + if( _disabled && !force_enable ) return session(*this); + bool disable_on_exit = _disabled && force_enable; + if( force_enable ) + _disabled = false; while( size() > max_size() ) _stack.pop_front(); _stack.emplace_back(); ++_active_sessions; - return session(*this); + return session(*this, disable_on_exit ); } void undo_database::on_create( const object& obj ) {