Skip to content

Commit

Permalink
Merge pull request #1247 from pmconrad/fix_proposal_undo
Browse files Browse the repository at this point in the history
Allow sufficient space for new undo_session
  • Loading branch information
pmconrad authored Aug 12, 2018
2 parents 2eb6132 + b467e62 commit 4b915ef
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions libraries/chain/db_block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,8 @@ processed_transaction database::validate_transaction( const signed_transaction&

processed_transaction database::push_proposal(const proposal_object& proposal)
{ try {
FC_ASSERT( _undo_db.size() < _undo_db.max_size(), "Undo database is full!" );

transaction_evaluation_state eval_state(this);
eval_state._is_proposed_trx = true;

Expand Down Expand Up @@ -569,6 +571,19 @@ processed_transaction database::apply_transaction(const signed_transaction& trx,
return result;
}

class undo_size_restorer {
public:
undo_size_restorer( undo_database& db ) : _db( db ), old_max( db.max_size() ) {
_db.set_max_size( old_max * 2 );
}
~undo_size_restorer() {
_db.set_max_size( old_max );
}
private:
undo_database& _db;
size_t old_max;
};

processed_transaction database::_apply_transaction(const signed_transaction& trx)
{ try {
uint32_t skip = get_node_properties().skip_flags;
Expand Down Expand Up @@ -622,6 +637,7 @@ processed_transaction database::_apply_transaction(const signed_transaction& trx

eval_state.operation_results.reserve(trx.operations.size());

const undo_size_restorer undo_guard( _undo_db );
//Finally process the operations
processed_transaction ptrx(trx);
_current_op_in_trx = 0;
Expand Down

0 comments on commit 4b915ef

Please sign in to comment.