Initialize recently_missed_count to 0 if slots were missed at genesis

This commit is contained in:
theoreticalbts 2015-08-26 18:59:19 -04:00
parent 013033001f
commit 4a350a5c0c
2 changed files with 28 additions and 1 deletions

View file

@ -42,7 +42,9 @@ void database::update_global_dynamic_data( const signed_block& b )
// dynamic global properties updating
modify( _dgp, [&]( dynamic_global_property_object& dgp ){
if( _checkpoints.size() && _checkpoints.rbegin()->first >= b.block_num() )
if( BOOST_UNLIKELY( b.block_num() == 1 ) )
dgp.recently_missed_count = 0;
else if( _checkpoints.size() && _checkpoints.rbegin()->first >= b.block_num() )
dgp.recently_missed_count = 0;
else if( missed_blocks )
dgp.recently_missed_count += GRAPHENE_RECENTLY_MISSED_COUNT_INCREMENT*missed_blocks;

View file

@ -26,12 +26,35 @@
#include <fc/smart_ref_impl.hpp>
#include <fc/thread/thread.hpp>
#include <iostream>
using namespace graphene::witness_plugin;
using std::string;
using std::vector;
namespace bpo = boost::program_options;
void new_chain_banner( const graphene::chain::database& db )
{
std::cerr << "\n"
"********************************\n"
"* *\n"
"* ------- NEW CHAIN ------ *\n"
"* - Welcome to Graphene! - *\n"
"* ------------------------ *\n"
"* *\n"
"********************************\n"
"\n";
if( db.get_slot_at_time( graphene::time::now() ) > 200 )
{
std::cerr << "Your genesis seems to have an old timestamp\n"
"Please consider using a script to produce a genesis file with a recent timestamp\n"
"\n"
;
}
return;
}
void witness_plugin::plugin_set_program_options(
boost::program_options::options_description& command_line_options,
boost::program_options::options_description& config_file_options)
@ -138,6 +161,8 @@ void witness_plugin::plugin_startup()
{
ilog("Launching block production for ${n} witnesses.", ("n", _witnesses.size()));
app().set_block_production(true);
if( _production_enabled && (d.head_block_num() == 0) )
new_chain_banner(d);
schedule_next_production(d.get_global_properties().parameters);
} else
elog("No witnesses configured! Please add witness IDs and private keys to configuration.");