debug_api: Take application object, not database, as parameter #606
This commit is contained in:
parent
77ac461a8a
commit
c37c2d4543
3 changed files with 14 additions and 9 deletions
|
|
@ -99,7 +99,7 @@ namespace graphene { namespace app {
|
||||||
{
|
{
|
||||||
// can only enable this API if the plugin was loaded
|
// can only enable this API if the plugin was loaded
|
||||||
if( _app.get_plugin( "debug_witness" ) )
|
if( _app.get_plugin( "debug_witness" ) )
|
||||||
_debug_api = std::make_shared< graphene::debug_witness::debug_api >( _app.chain_database() );
|
_debug_api = std::make_shared< graphene::debug_witness::debug_api >( std::ref(_app) );
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@
|
||||||
#include <fc/optional.hpp>
|
#include <fc/optional.hpp>
|
||||||
#include <fc/variant_object.hpp>
|
#include <fc/variant_object.hpp>
|
||||||
|
|
||||||
|
#include <graphene/app/application.hpp>
|
||||||
|
|
||||||
#include <graphene/chain/block_database.hpp>
|
#include <graphene/chain/block_database.hpp>
|
||||||
#include <graphene/chain/database.hpp>
|
#include <graphene/chain/database.hpp>
|
||||||
#include <graphene/chain/witness_object.hpp>
|
#include <graphene/chain/witness_object.hpp>
|
||||||
|
|
@ -18,17 +20,17 @@ namespace detail {
|
||||||
class debug_api_impl
|
class debug_api_impl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
debug_api_impl( std::shared_ptr< graphene::chain::database >& _db );
|
debug_api_impl( graphene::app::application& _app );
|
||||||
|
|
||||||
void debug_push_blocks( const std::string& src_filename, uint32_t count );
|
void debug_push_blocks( const std::string& src_filename, uint32_t count );
|
||||||
void debug_generate_blocks( const std::string& debug_key, uint32_t count );
|
void debug_generate_blocks( const std::string& debug_key, uint32_t count );
|
||||||
void debug_update_object( const fc::variant_object& update );
|
void debug_update_object( const fc::variant_object& update );
|
||||||
//void debug_save_db( std::string db_path );
|
//void debug_save_db( std::string db_path );
|
||||||
|
|
||||||
std::shared_ptr< graphene::chain::database > db;
|
graphene::app::application& app;
|
||||||
};
|
};
|
||||||
|
|
||||||
debug_api_impl::debug_api_impl( std::shared_ptr< graphene::chain::database >& _db ) : db( _db )
|
debug_api_impl::debug_api_impl( graphene::app::application& _app ) : app( _app )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -37,6 +39,7 @@ void debug_api_impl::debug_push_blocks( const std::string& src_filename, uint32_
|
||||||
if( count == 0 )
|
if( count == 0 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
std::shared_ptr< graphene::chain::database > db = app.chain_database();
|
||||||
fc::path src_path = fc::path( src_filename );
|
fc::path src_path = fc::path( src_filename );
|
||||||
if( fc::is_directory( src_path ) )
|
if( fc::is_directory( src_path ) )
|
||||||
{
|
{
|
||||||
|
|
@ -76,6 +79,7 @@ void debug_api_impl::debug_generate_blocks( const std::string& debug_key, uint32
|
||||||
FC_ASSERT( debug_private_key.valid() );
|
FC_ASSERT( debug_private_key.valid() );
|
||||||
graphene::chain::public_key_type debug_public_key = debug_private_key->get_public_key();
|
graphene::chain::public_key_type debug_public_key = debug_private_key->get_public_key();
|
||||||
|
|
||||||
|
std::shared_ptr< graphene::chain::database > db = app.chain_database();
|
||||||
for( uint32_t i=0; i<count; i++ )
|
for( uint32_t i=0; i<count; i++ )
|
||||||
{
|
{
|
||||||
graphene::chain::witness_id_type scheduled_witness = db->get_scheduled_witness( 1 );
|
graphene::chain::witness_id_type scheduled_witness = db->get_scheduled_witness( 1 );
|
||||||
|
|
@ -94,14 +98,15 @@ void debug_api_impl::debug_generate_blocks( const std::string& debug_key, uint32
|
||||||
|
|
||||||
void debug_api_impl::debug_update_object( const fc::variant_object& update )
|
void debug_api_impl::debug_update_object( const fc::variant_object& update )
|
||||||
{
|
{
|
||||||
|
std::shared_ptr< graphene::chain::database > db = app.chain_database();
|
||||||
db->debug_update( update );
|
db->debug_update( update );
|
||||||
}
|
}
|
||||||
|
|
||||||
} // detail
|
} // detail
|
||||||
|
|
||||||
debug_api::debug_api( std::shared_ptr< graphene::chain::database > db )
|
debug_api::debug_api( graphene::app::application& app )
|
||||||
{
|
{
|
||||||
my = std::make_shared< detail::debug_api_impl >(db);
|
my = std::make_shared< detail::debug_api_impl >(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
void debug_api::debug_push_blocks( std::string source_filename, uint32_t count )
|
void debug_api::debug_push_blocks( std::string source_filename, uint32_t count )
|
||||||
|
|
|
||||||
|
|
@ -29,8 +29,8 @@
|
||||||
#include <fc/api.hpp>
|
#include <fc/api.hpp>
|
||||||
#include <fc/variant_object.hpp>
|
#include <fc/variant_object.hpp>
|
||||||
|
|
||||||
namespace graphene { namespace chain {
|
namespace graphene { namespace app {
|
||||||
class database;
|
class application;
|
||||||
} }
|
} }
|
||||||
|
|
||||||
namespace graphene { namespace debug_witness {
|
namespace graphene { namespace debug_witness {
|
||||||
|
|
@ -42,7 +42,7 @@ class debug_api_impl;
|
||||||
class debug_api
|
class debug_api
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
debug_api( std::shared_ptr<graphene::chain::database> db );
|
debug_api( graphene::app::application& app );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Push blocks from existing database.
|
* Push blocks from existing database.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue