MCPcopy Create free account
hub / github.com/cryptonomex/graphene / update_global_dynamic_data

Method update_global_dynamic_data

libraries/chain/db_update.cpp:38–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36namespace graphene { namespace chain {
37
38void database::update_global_dynamic_data( const signed_block& b )
39{
40 const dynamic_global_property_object& _dgp =
41 dynamic_global_property_id_type(0)(*this);
42
43 uint32_t missed_blocks = get_slot_at_time( b.timestamp );
44 assert( missed_blocks != 0 );
45 missed_blocks--;
46 for( uint32_t i = 0; i < missed_blocks; ++i ) {
47 const auto& witness_missed = get_scheduled_witness( i+1 )(*this);
48 if( witness_missed.id != b.witness ) {
49 /*
50 const auto& witness_account = witness_missed.witness_account(*this);
51 if( (fc::time_point::now() - b.timestamp) < fc::seconds(30) )
52 wlog( "Witness ${name} missed block ${n} around ${t}", ("name",witness_account.name)("n",b.block_num())("t",b.timestamp) );
53 */
54
55 modify( witness_missed, [&]( witness_object& w ) {
56 w.total_missed++;
57 });
58 }
59 }
60
61 // dynamic global properties updating
62 modify( _dgp, [&]( dynamic_global_property_object& dgp ){
63 if( BOOST_UNLIKELY( b.block_num() == 1 ) )
64 dgp.recently_missed_count = 0;
65 else if( _checkpoints.size() && _checkpoints.rbegin()->first >= b.block_num() )
66 dgp.recently_missed_count = 0;
67 else if( missed_blocks )
68 dgp.recently_missed_count += GRAPHENE_RECENTLY_MISSED_COUNT_INCREMENT*missed_blocks;
69 else if( dgp.recently_missed_count > GRAPHENE_RECENTLY_MISSED_COUNT_INCREMENT )
70 dgp.recently_missed_count -= GRAPHENE_RECENTLY_MISSED_COUNT_DECREMENT;
71 else if( dgp.recently_missed_count > 0 )
72 dgp.recently_missed_count--;
73
74 dgp.head_block_number = b.block_num();
75 dgp.head_block_id = b.id();
76 dgp.time = b.timestamp;
77 dgp.current_witness = b.witness;
78 dgp.recent_slots_filled = (
79 (dgp.recent_slots_filled << 1)
80 + 1) << missed_blocks;
81 dgp.current_aslot += missed_blocks+1;
82 });
83
84 if( !(get_node_properties().skip_flags & skip_undo_history_check) )
85 {
86 GRAPHENE_ASSERT( _dgp.head_block_number - _dgp.last_irreversible_block_num < GRAPHENE_MAX_UNDO_HISTORY, undo_database_exception,
87 "The database does not have enough undo history to support a blockchain with so many missed blocks. "
88 "Please add a checkpoint if you would like to continue applying blocks beyond this point.",
89 ("last_irreversible_block_num",_dgp.last_irreversible_block_num)("head", _dgp.head_block_number)
90 ("recently_missed",_dgp.recently_missed_count)("max_undo",GRAPHENE_MAX_UNDO_HISTORY) );
91 }
92
93 _undo_db.set_max_size( _dgp.head_block_number - _dgp.last_irreversible_block_num + 1 );
94 _fork_db.set_max_size( _dgp.head_block_number - _dgp.last_irreversible_block_num + 1 );
95}

Callers

nothing calls this directly

Calls 4

block_numMethod · 0.80
sizeMethod · 0.45
idMethod · 0.45
set_max_sizeMethod · 0.45

Tested by

no test coverage detected