Merge branch '481-history-failed-proposal-ops' into develop
This commit is contained in:
commit
3680b67271
6 changed files with 45 additions and 14 deletions
|
|
@ -1625,8 +1625,12 @@ void database_api_impl::on_applied_block()
|
|||
|
||||
const auto& ops = _db.get_applied_operations();
|
||||
map< std::pair<asset_id_type,asset_id_type>, vector<pair<operation, operation_result>> > subscribed_markets_ops;
|
||||
for(const auto& op : ops)
|
||||
for(const optional< operation_history_object >& o_op : ops)
|
||||
{
|
||||
if( !o_op.valid() )
|
||||
continue;
|
||||
const operation_history_object& op = *o_op;
|
||||
|
||||
std::pair<asset_id_type,asset_id_type> market;
|
||||
switch(op.op.which())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include <graphene/chain/database.hpp>
|
||||
#include <graphene/chain/db_with.hpp>
|
||||
#include <graphene/chain/hardfork.hpp>
|
||||
|
||||
#include <graphene/chain/block_summary_object.hpp>
|
||||
#include <graphene/chain/global_property_object.hpp>
|
||||
|
|
@ -257,6 +258,7 @@ processed_transaction database::push_proposal(const proposal_object& proposal)
|
|||
eval_state.operation_results.reserve(proposal.proposed_transaction.operations.size());
|
||||
processed_transaction ptrx(proposal.proposed_transaction);
|
||||
eval_state._trx = &ptrx;
|
||||
size_t old_applied_ops_size = _applied_ops.size();
|
||||
|
||||
try {
|
||||
auto session = _undo_db.start_undo_session(true);
|
||||
|
|
@ -265,6 +267,18 @@ processed_transaction database::push_proposal(const proposal_object& proposal)
|
|||
remove(proposal);
|
||||
session.merge();
|
||||
} catch ( const fc::exception& e ) {
|
||||
if( head_block_time() <= HARDFORK_483_TIME )
|
||||
{
|
||||
for( size_t i=old_applied_ops_size,n=_applied_ops.size(); i<n; i++ )
|
||||
{
|
||||
ilog( "removing failed operation from applied_ops: ${op}", ("op", *(_applied_ops[i])) );
|
||||
_applied_ops[i].reset();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_applied_ops.resize( old_applied_ops_size );
|
||||
}
|
||||
elog( "e", ("e",e.to_detail_string() ) );
|
||||
throw;
|
||||
}
|
||||
|
|
@ -418,7 +432,7 @@ void database::clear_pending()
|
|||
uint32_t database::push_applied_operation( const operation& op )
|
||||
{
|
||||
_applied_ops.emplace_back(op);
|
||||
auto& oh = _applied_ops.back();
|
||||
operation_history_object& oh = *(_applied_ops.back());
|
||||
oh.block_num = _current_block_num;
|
||||
oh.trx_in_block = _current_trx_in_block;
|
||||
oh.op_in_trx = _current_op_in_trx;
|
||||
|
|
@ -428,10 +442,10 @@ uint32_t database::push_applied_operation( const operation& op )
|
|||
void database::set_applied_operation_result( uint32_t op_id, const operation_result& result )
|
||||
{
|
||||
assert( op_id < _applied_ops.size() );
|
||||
_applied_ops[op_id].result = result;
|
||||
_applied_ops[op_id]->result = result;
|
||||
}
|
||||
|
||||
const vector<operation_history_object>& database::get_applied_operations() const
|
||||
const vector<optional< operation_history_object > >& database::get_applied_operations() const
|
||||
{
|
||||
return _applied_ops;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ namespace graphene { namespace chain {
|
|||
*/
|
||||
uint32_t push_applied_operation( const operation& op );
|
||||
void set_applied_operation_result( uint32_t op_id, const operation_result& r );
|
||||
const vector<operation_history_object>& get_applied_operations()const;
|
||||
const vector<optional< operation_history_object > >& get_applied_operations()const;
|
||||
|
||||
string to_pretty_string( const asset& a )const;
|
||||
|
||||
|
|
@ -473,7 +473,7 @@ namespace graphene { namespace chain {
|
|||
* order they occur and is cleared after the applied_block signal is
|
||||
* emited.
|
||||
*/
|
||||
vector<operation_history_object> _applied_ops;
|
||||
vector<optional<operation_history_object> > _applied_ops;
|
||||
|
||||
uint32_t _current_block_num = 0;
|
||||
uint16_t _current_trx_in_block = 0;
|
||||
|
|
|
|||
|
|
@ -37,3 +37,5 @@
|
|||
// #453 Hardfork to retroactively correct referral percentages
|
||||
#define HARDFORK_453_TIME (fc::time_point_sec( 1450288800 ))
|
||||
#define HARDFORK_480_TIME (fc::time_point_sec( 1450378800 ))
|
||||
// #483 Operation history numbering change
|
||||
#define HARDFORK_483_TIME (fc::time_point_sec( 1450378800 ))
|
||||
|
|
|
|||
|
|
@ -71,13 +71,24 @@ account_history_plugin_impl::~account_history_plugin_impl()
|
|||
void account_history_plugin_impl::update_account_histories( const signed_block& b )
|
||||
{
|
||||
graphene::chain::database& db = database();
|
||||
const vector<operation_history_object>& hist = db.get_applied_operations();
|
||||
for( auto op : hist )
|
||||
const vector<optional< operation_history_object > >& hist = db.get_applied_operations();
|
||||
for( const optional< operation_history_object >& o_op : hist )
|
||||
{
|
||||
// add to the operation history index
|
||||
const auto& oho = db.create<operation_history_object>( [&]( operation_history_object& h ){
|
||||
h = op;
|
||||
});
|
||||
const auto& oho = db.create<operation_history_object>( [&]( operation_history_object& h )
|
||||
{
|
||||
if( o_op.valid() )
|
||||
h = *o_op;
|
||||
} );
|
||||
|
||||
if( !o_op.valid() )
|
||||
{
|
||||
ilog( "removing failed operation with ID: ${id}", ("id", oho.id) );
|
||||
db.remove( oho );
|
||||
continue;
|
||||
}
|
||||
|
||||
const operation_history_object& op = *o_op;
|
||||
|
||||
// get the set of accounts this operation applies to
|
||||
flat_set<account_id_type> impacted;
|
||||
|
|
|
|||
|
|
@ -216,9 +216,9 @@ void market_history_plugin_impl::update_market_histories( const signed_block& b
|
|||
if( _tracked_buckets.size() == 0 ) return;
|
||||
|
||||
graphene::chain::database& db = database();
|
||||
const vector<operation_history_object>& hist = db.get_applied_operations();
|
||||
for( auto op : hist )
|
||||
op.op.visit( operation_process_fill_order( _self, b.timestamp ) );
|
||||
const vector<optional< operation_history_object > >& hist = db.get_applied_operations();
|
||||
for( const optional< operation_history_object >& o_op : hist )
|
||||
o_op->op.visit( operation_process_fill_order( _self, b.timestamp ) );
|
||||
}
|
||||
|
||||
} // end namespace detail
|
||||
|
|
|
|||
Loading…
Reference in a new issue