fix reindex with failed proposed transaction

This commit is contained in:
Daniel Larimer 2015-09-29 10:49:12 -04:00
parent d3b283b60e
commit edcd46dd14
7 changed files with 34 additions and 19 deletions

View file

@ -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<abstract_plugin> application::get_plugin(const string& name) const

View file

@ -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,

View file

@ -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)

View file

@ -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;

View file

@ -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

View file

@ -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
*/

View file

@ -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 )
{