void burn_operation::evaluate( transaction_evaluation_state& eval_state ) { try { if( message.size() ) FC_ASSERT( amount.asset_id == 0 ); if( amount.asset_id == 0 ) { FC_ASSERT( amount.amount >= BTS_BLOCKCHAIN_MIN_BURN_FEE, "", ("amount",amount) ("BTS_BLOCKCHAIN_MIN_BURN_FEE",BTS_BLOCKCHAIN_MIN_BURN_FEE) ); } oasset_record asset_rec = eval_state._current_state->get_asset_record( amount.asset_id ); FC_ASSERT( asset_rec.valid() ); FC_ASSERT( !asset_rec->is_market_issued() ); asset_rec->current_share_supply -= this->amount.amount; eval_state.sub_balance( address(), this->amount ); eval_state._current_state->store_asset_record( *asset_rec ); if( account_id != 0 ) // you can offer burnt offerings to God if you like... otherwise it must be an account { // TODO: support burning to any OBJECT ID not just accounts const oaccount_record account_rec = eval_state._current_state->get_account_record( abs( this->account_id ) ); FC_ASSERT( account_rec.valid() ); } eval_state._current_state->store_burn_record( burn_record( burn_record_key( {account_id, eval_state.trx.id()} ), burn_record_value( {amount,message,message_signature} ) ) ); } FC_CAPTURE_AND_RETHROW( (*this) ) }
oburn_record pending_chain_state::fetch_burn_record( const burn_record_key& key )const { auto itr = burns.find(key); if( itr == burns.end() ) { chain_interface_ptr prev_state = _prev_state.lock(); return prev_state->fetch_burn_record( key ); } return burn_record( itr->first, itr->second ); }
void pending_chain_state::get_undo_state( const chain_interface_ptr& undo_state_arg )const { auto undo_state = std::dynamic_pointer_cast<pending_chain_state>( undo_state_arg ); chain_interface_ptr prev_state = _prev_state.lock(); FC_ASSERT( prev_state ); for( const auto& item : properties ) { auto prev_value = prev_state->get_property( (chain_property_enum)item.first ); undo_state->set_property( (chain_property_enum)item.first, prev_value ); } for( const auto& item : assets ) { auto prev_value = prev_state->get_asset_record( item.first ); if( !!prev_value ) undo_state->store_asset_record( *prev_value ); else undo_state->store_asset_record( item.second.make_null() ); } for( const auto& item : slates ) { auto prev_value = prev_state->get_delegate_slate( item.first ); if( prev_value ) undo_state->store_delegate_slate( item.first, *prev_value ); else undo_state->store_delegate_slate( item.first, delegate_slate() ); } for( const auto& item : accounts ) { auto prev_value = prev_state->get_account_record( item.first ); if( !!prev_value ) undo_state->store_account_record( *prev_value ); else undo_state->store_account_record( item.second.make_null() ); } #if 0 for( const auto& item : proposals ) { auto prev_value = prev_state->get_proposal_record( item.first ); if( !!prev_value ) undo_state->store_proposal_record( *prev_value ); else undo_state->store_proposal_record( item.second.make_null() ); } for( const auto& item : proposal_votes ) { auto prev_value = prev_state->get_proposal_vote( item.first ); if( !!prev_value ) undo_state->store_proposal_vote( *prev_value ); else { undo_state->store_proposal_vote( item.second.make_null() ); } } #endif for( const auto& item : balances ) { auto prev_value = prev_state->get_balance_record( item.first ); if( !!prev_value ) undo_state->store_balance_record( *prev_value ); else undo_state->store_balance_record( item.second.make_null() ); } for( const auto& item : transactions ) { auto prev_value = prev_state->get_transaction( item.first ); if( !!prev_value ) undo_state->store_transaction( item.first, *prev_value ); else undo_state->store_transaction( item.first, transaction_record() ); } for( const auto& item : bids ) { auto prev_value = prev_state->get_bid_record( item.first ); if( prev_value.valid() ) undo_state->store_bid_record( item.first, *prev_value ); else undo_state->store_bid_record( item.first, order_record() ); } for( const auto& item : asks ) { auto prev_value = prev_state->get_ask_record( item.first ); if( prev_value.valid() ) undo_state->store_ask_record( item.first, *prev_value ); else undo_state->store_ask_record( item.first, order_record() ); } for( const auto& item : shorts ) { auto prev_value = prev_state->get_short_record( item.first ); if( prev_value.valid() ) undo_state->store_short_record( item.first, *prev_value ); else undo_state->store_short_record( item.first, order_record() ); } for( const auto& item : collateral ) { auto prev_value = prev_state->get_collateral_record( item.first ); if( prev_value.valid() ) undo_state->store_collateral_record( item.first, *prev_value ); else undo_state->store_collateral_record( item.first, collateral_record() ); } for( const auto& item : slots ) { auto prev_value = prev_state->get_slot_record( item.first ); if( prev_value ) undo_state->store_slot_record( *prev_value ); else { slot_record invalid_slot_record; invalid_slot_record.start_time = item.first; invalid_slot_record.block_produced = true; invalid_slot_record.block_id = block_id_type(); undo_state->store_slot_record( invalid_slot_record ); } } for( const auto& item : market_statuses ) { auto prev_value = prev_state->get_market_status( item.first.first, item.first.second ); if( prev_value ) undo_state->store_market_status( *prev_value ); else { undo_state->store_market_status( market_status() ); } } for( const auto& item : feeds ) { auto prev_value = prev_state->get_feed( item.first ); if( prev_value ) undo_state->set_feed( *prev_value ); else undo_state->set_feed( feed_record{item.first} ); } for( const auto& item : burns ) { undo_state->store_burn_record( burn_record( item.first ) ); } const auto dirty_markets = prev_state->get_dirty_markets(); undo_state->set_dirty_markets(dirty_markets); /* NOTE: Recent operations are currently not rewound on undo */ }