Skip to content

Commit

Permalink
Update head_block_time during block generation for automated actions
Browse files Browse the repository at this point in the history
  • Loading branch information
mvandeberg committed Feb 3, 2020
1 parent 62274cf commit 3c100b4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
10 changes: 1 addition & 9 deletions libraries/chain/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3035,12 +3035,6 @@ void database::_apply_block( const signed_block& next_block )

const uint32_t next_block_num = note.block_num;

BOOST_SCOPE_EXIT( this_ )
{
this_->_currently_processing_block_id.reset();
} BOOST_SCOPE_EXIT_END
_currently_processing_block_id = note.block_id;

uint32_t skip = get_node_properties().skip_flags;

_current_block_num = next_block_num;
Expand Down Expand Up @@ -3858,9 +3852,7 @@ void database::update_global_dynamic_data( const signed_block& b )
}

dgp.head_block_number = b.block_num();
// Following FC_ASSERT should never fail, as _currently_processing_block_id is always set by caller
FC_ASSERT( _currently_processing_block_id.valid() );
dgp.head_block_id = *_currently_processing_block_id;
dgp.head_block_id = b.id();
dgp.time = b.timestamp;
dgp.current_aslot += missed_blocks+1;
} );
Expand Down
7 changes: 2 additions & 5 deletions libraries/chain/include/steem/chain/database.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ namespace steem { namespace chain {
bool is_pending_tx()const { return _is_pending_tx; }
void set_pending_tx( bool p ) { _is_pending_tx = p; }

bool is_processing_block()const { return _currently_processing_block_id.valid(); }

bool _is_producing = false;
bool _is_pending_tx = false;

Expand Down Expand Up @@ -483,6 +481,8 @@ namespace steem { namespace chain {
void retally_liquidity_weight();
void update_virtual_supply();

void update_global_dynamic_data( const signed_block& b );

bool has_hardfork( uint32_t hardfork )const;

uint32_t get_hardfork()const;
Expand Down Expand Up @@ -550,7 +550,6 @@ namespace steem { namespace chain {

void process_proposals( const block_notification& note );

void update_global_dynamic_data( const signed_block& b );
void update_signing_witness(const witness_object& signing_witness, const signed_block& new_block);
void update_last_irreversible_block();
void migrate_irreversible_state();
Expand Down Expand Up @@ -633,8 +632,6 @@ namespace steem { namespace chain {
uint16_t _current_op_in_trx = 0;
uint16_t _current_virtual_op = 0;

optional< block_id_type > _currently_processing_block_id;

flat_map<uint32_t,block_id_type> _checkpoints;

node_property_object _node_property_object;
Expand Down
12 changes: 10 additions & 2 deletions libraries/plugins/witness/block_producer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

#include <fc/macros.hpp>

#include <boost/scope_exit.hpp>

namespace steem { namespace plugins { namespace witness {

chain::signed_block block_producer::generate_block(fc::time_point_sec when, const chain::account_name_type& witness_owner, const fc::ecc::private_key& block_signing_private_key, uint32_t skip)
Expand Down Expand Up @@ -41,7 +43,7 @@ chain::signed_block block_producer::generate_block(fc::time_point_sec when, cons
}

chain::signed_block block_producer::_generate_block(fc::time_point_sec when, const chain::account_name_type& witness_owner, const fc::ecc::private_key& block_signing_private_key)
{
{ try {
uint32_t skip = _db.get_node_properties().skip_flags;
uint32_t slot_num = _db.get_slot_at_time( when );
FC_ASSERT( slot_num > 0 );
Expand Down Expand Up @@ -81,7 +83,7 @@ chain::signed_block block_producer::_generate_block(fc::time_point_sec when, con
_db.push_block( pending_block, skip );

return pending_block;
}
} FC_LOG_AND_RETHROW() }

void block_producer::adjust_hardfork_version_vote(const chain::witness_object& witness, chain::signed_block& pending_block)
{
Expand Down Expand Up @@ -134,6 +136,8 @@ void block_producer::apply_pending_transactions(
_db.pending_transaction_session().reset();
_db.pending_transaction_session() = _db.start_undo_session();

_db.update_global_dynamic_data( pending_block );

FC_TODO( "Safe to remove after HF20 occurs because no more pre HF20 blocks will be generated" );
if( _db.has_hardfork( STEEM_HARDFORK_0_20 ) )
{
Expand Down Expand Up @@ -210,6 +214,9 @@ void block_producer::apply_pending_transactions(
total_block_size = new_total_size;
required_actions.push_back( pending_required_itr->action );

_db.remove( *pending_required_itr );
pending_required_itr = pending_required_action_idx.begin();
/*
#ifdef ENABLE_MIRA
auto old = pending_required_itr++;
if( !( pending_required_itr != pending_required_action_idx.end() && pending_required_itr->execution_time <= when ) )
Expand All @@ -220,6 +227,7 @@ void block_producer::apply_pending_transactions(
#else
++pending_required_itr;
#endif
*/
}
catch( fc::exception& e )
{
Expand Down

0 comments on commit 3c100b4

Please sign in to comment.