Skip to content

Commit

Permalink
Update to use chainbase
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Vandeberg committed Nov 4, 2016
1 parent b44b9b1 commit 160bc44
Show file tree
Hide file tree
Showing 30 changed files with 276 additions and 249 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "libraries/fc"]
path = libraries/fc
url = https://github.com/steemit/fc.git
[submodule "libraries/chainbase"]
path = libraries/chainbase
url = ihttps://github.com/steemit/chainbase.git

This comment has been minimized.

Copy link
@xeroc

xeroc Nov 4, 2016

typo right here ihttps -> https

3 changes: 2 additions & 1 deletion libraries/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
add_subdirectory( fc )
add_subdirectory( schema )
add_subdirectory( db2 )
add_subdirectory( chainbase )
#add_subdirectory( db2 )
#add_subdirectory( chain2 )
add_subdirectory( chain )
add_subdirectory( protocol )
Expand Down
2 changes: 1 addition & 1 deletion libraries/chain/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ add_library( steemit_chain
)

add_dependencies( steemit_chain steemit_protocol build_hardfork_hpp )
target_link_libraries( steemit_chain steemit_protocol fc graphene_db2 ${PATCH_MERGE_LIB} )
target_link_libraries( steemit_chain steemit_protocol fc chainbase graphene_schema ${PATCH_MERGE_LIB} )
target_include_directories( steemit_chain
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" "${CMAKE_CURRENT_BINARY_DIR}/include" )

Expand Down
60 changes: 30 additions & 30 deletions libraries/chain/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

namespace steemit { namespace chain {

namespace db2 = graphene::db2;
//namespace db2 = graphene::db2;

struct object_schema_repr
{
Expand Down Expand Up @@ -96,7 +96,7 @@ void database::open( const fc::path& data_dir, uint64_t initial_supply, uint64_t
try
{
init_schema();
db2::database::open( data_dir, shared_file_size );
chainbase::database::open( data_dir, chainbase::database::read_write, shared_file_size );

with_write_lock( [&]()
{
Expand Down Expand Up @@ -184,7 +184,7 @@ void database::reindex( fc::path data_dir, uint64_t shared_file_size )
void database::wipe(const fc::path& data_dir, bool include_blocks)
{
close();
db2::database::wipe( data_dir );
chainbase::database::wipe( data_dir );
if( include_blocks )
fc::remove_all( data_dir / "block_log" );
}
Expand All @@ -198,8 +198,8 @@ void database::close(bool rewind)
// DB state (issue #336).
clear_pending();

db2::database::flush();
db2::database::close();
chainbase::database::flush();
chainbase::database::close();

_block_log.close();

Expand Down Expand Up @@ -295,72 +295,72 @@ chain_id_type database::get_chain_id() const
}

const witness_object& database::get_witness( const account_name_type& name ) const
{
{ try {
return get< witness_object, by_name >( name );
}
} FC_CAPTURE_AND_RETHROW( (name) ) }

const witness_object* database::find_witness( const account_name_type& name ) const
{
return find< witness_object, by_name >( name );
}

const account_object& database::get_account( const account_name_type& name )const
{
{ try {
return get< account_object, by_name >( name );
}
} FC_CAPTURE_AND_RETHROW( (name) ) }

const account_object* database::find_account( const account_name_type& name )const
{
return find< account_object, by_name >( name );
}

const comment_object& database::get_comment( const account_name_type& author, const shared_string& permlink )const
{
{ try {
return get< comment_object, by_permlink >( boost::make_tuple( author, permlink ) );
}
} FC_CAPTURE_AND_RETHROW( (author)(permlink) ) }

const comment_object* database::find_comment( const account_name_type& author, const shared_string& permlink )const
{
return find< comment_object, by_permlink >( boost::make_tuple( author, permlink ) );
}

const comment_object& database::get_comment( const account_name_type& author, const string& permlink )const
{
{ try {
return get< comment_object, by_permlink >( boost::make_tuple( author, permlink) );
}
} FC_CAPTURE_AND_RETHROW( (author)(permlink) ) }

const comment_object* database::find_comment( const account_name_type& author, const string& permlink )const
{
return find< comment_object, by_permlink >( boost::make_tuple( author, permlink ) );
}

const category_object& database::get_category( const shared_string& name )const
{
{ try {
return get< category_object, by_name >( name );
}
} FC_CAPTURE_AND_RETHROW( (name) ) }

const category_object* database::find_category( const shared_string& name )const
{
return find< category_object, by_name >( name );
}

const escrow_object& database::get_escrow( const account_name_type& name, uint32_t escrow_id )const
{
{ try {
return get< escrow_object, by_from_id >( boost::make_tuple( name, escrow_id ) );
}
} FC_CAPTURE_AND_RETHROW( (name)(escrow_id) ) }

const escrow_object* database::find_escrow( const account_name_type& name, uint32_t escrow_id )const
{
return find< escrow_object, by_from_id >( boost::make_tuple( name, escrow_id ) );
}

const limit_order_object& database::get_limit_order( const account_name_type& name, uint32_t orderid )const
{
{ try {
if( !has_hardfork( STEEMIT_HARDFORK_0_6__127 ) )
orderid = orderid & 0x0000FFFF;

return get< limit_order_object, by_account >( boost::make_tuple( name, orderid ) );
}
} FC_CAPTURE_AND_RETHROW( (name)(orderid) ) }

const limit_order_object* database::find_limit_order( const account_name_type& name, uint32_t orderid )const
{
Expand All @@ -371,39 +371,39 @@ const limit_order_object* database::find_limit_order( const account_name_type& n
}

const savings_withdraw_object& database::get_savings_withdraw( const account_name_type& owner, uint32_t request_id )const
{
{ try {
return get< savings_withdraw_object, by_from_rid >( boost::make_tuple( owner, request_id ) );
}
} FC_CAPTURE_AND_RETHROW( (owner)(request_id) ) }

const savings_withdraw_object* database::find_savings_withdraw( const account_name_type& owner, uint32_t request_id )const
{
return find< savings_withdraw_object, by_from_rid >( boost::make_tuple( owner, request_id ) );
}

const dynamic_global_property_object&database::get_dynamic_global_properties() const
{
{ try {
return get< dynamic_global_property_object >();
}
} FC_CAPTURE_AND_RETHROW() }

const node_property_object& database::get_node_properties() const
{
return _node_property_object;
}

const feed_history_object& database::get_feed_history()const
{
{ try {
return get< feed_history_object >();
}
} FC_CAPTURE_AND_RETHROW() }

const witness_schedule_object& database::get_witness_schedule_object()const
{
{ try {
return get< witness_schedule_object >();
}
} FC_CAPTURE_AND_RETHROW() }

const hardfork_property_object& database::get_hardfork_property_object()const
{
{ try {
return get< hardfork_property_object >();
}
} FC_CAPTURE_AND_RETHROW() }

const time_point_sec database::calculate_discussion_payout_time( const comment_object& comment )const
{
Expand Down Expand Up @@ -2754,7 +2754,7 @@ void database::notify_changed_objects()
{
try
{
/*vector< graphene::db2::generic_id > ids;
/*vector< graphene::chainbase::generic_id > ids;
get_changed_ids( ids );
STEEMIT_TRY_NOTIFY( changed_objects, ids )*/
/*
Expand Down
2 changes: 1 addition & 1 deletion libraries/chain/hardfork.d/0-preamble.hf
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ typedef multi_index_container<
FC_REFLECT( steemit::chain::hardfork_property_object,
(id)(processed_hardforks)(last_hardfork)(current_hardfork_version)
(next_hardfork)(next_hardfork_time) )
SET_INDEX_TYPE( steemit::chain::hardfork_property_object, steemit::chain::hardfork_property_index )
CHAINBASE_SET_INDEX_TYPE( steemit::chain::hardfork_property_object, steemit::chain::hardfork_property_index )

#define STEEMIT_NUM_HARDFORKS 15
10 changes: 5 additions & 5 deletions libraries/chain/include/steemit/chain/account_object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,24 +394,24 @@ FC_REFLECT( steemit::chain::account_object,
(average_market_bandwidth)(last_market_bandwidth_update)
(last_post)(last_root_post)(post_bandwidth)
)
SET_INDEX_TYPE( steemit::chain::account_object, steemit::chain::account_index )
CHAINBASE_SET_INDEX_TYPE( steemit::chain::account_object, steemit::chain::account_index )

FC_REFLECT( steemit::chain::account_authority_object,
(id)(account)(owner)(active)(posting)(last_owner_update)
)
SET_INDEX_TYPE( steemit::chain::account_authority_object, steemit::chain::account_authority_index )
CHAINBASE_SET_INDEX_TYPE( steemit::chain::account_authority_object, steemit::chain::account_authority_index )

FC_REFLECT( steemit::chain::owner_authority_history_object,
(id)(account)(previous_owner_authority)(last_valid_time)
)
SET_INDEX_TYPE( steemit::chain::owner_authority_history_object, steemit::chain::owner_authority_history_index )
CHAINBASE_SET_INDEX_TYPE( steemit::chain::owner_authority_history_object, steemit::chain::owner_authority_history_index )

FC_REFLECT( steemit::chain::account_recovery_request_object,
(id)(account_to_recover)(new_owner_authority)(expires)
)
SET_INDEX_TYPE( steemit::chain::account_recovery_request_object, steemit::chain::account_recovery_request_index )
CHAINBASE_SET_INDEX_TYPE( steemit::chain::account_recovery_request_object, steemit::chain::account_recovery_request_index )

FC_REFLECT( steemit::chain::change_recovery_account_request_object,
(id)(account_to_recover)(recovery_account)(effective_on)
)
SET_INDEX_TYPE( steemit::chain::change_recovery_account_request_object, steemit::chain::change_recovery_account_request_index )
CHAINBASE_SET_INDEX_TYPE( steemit::chain::change_recovery_account_request_object, steemit::chain::change_recovery_account_request_index )
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ namespace steemit { namespace chain {
} } // steemit::chain

FC_REFLECT( steemit::chain::block_summary_object, (id)(block_id) )
SET_INDEX_TYPE( steemit::chain::block_summary_object, steemit::chain::block_summary_index )
CHAINBASE_SET_INDEX_TYPE( steemit::chain::block_summary_object, steemit::chain::block_summary_index )

FC_REFLECT( steemit::chain::block_stats_object, (id)(block_id)(pos)(packed_block) )
SET_INDEX_TYPE( steemit::chain::block_stats_object, steemit::chain::block_stats_index )
CHAINBASE_SET_INDEX_TYPE( steemit::chain::block_stats_object, steemit::chain::block_stats_index )
6 changes: 3 additions & 3 deletions libraries/chain/include/steemit/chain/comment_object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,14 +325,14 @@ FC_REFLECT( steemit::chain::comment_object,
(total_vote_weight)(reward_weight)(total_payout_value)(curator_payout_value)(author_rewards)(net_votes)(root_comment)(mode)
(max_accepted_payout)(percent_steem_dollars)(allow_replies)(allow_votes)(allow_curation_rewards)
)
SET_INDEX_TYPE( steemit::chain::comment_object, steemit::chain::comment_index )
CHAINBASE_SET_INDEX_TYPE( steemit::chain::comment_object, steemit::chain::comment_index )

FC_REFLECT( steemit::chain::comment_vote_object,
(id)(voter)(comment)(weight)(rshares)(vote_percent)(last_update)(num_changes)
)
SET_INDEX_TYPE( steemit::chain::comment_vote_object, steemit::chain::comment_vote_index )
CHAINBASE_SET_INDEX_TYPE( steemit::chain::comment_vote_object, steemit::chain::comment_vote_index )

FC_REFLECT( steemit::chain::category_object,
(id)(name)(abs_rshares)(total_payouts)(discussions)(last_update)
)
SET_INDEX_TYPE( steemit::chain::category_object, steemit::chain::category_index )
CHAINBASE_SET_INDEX_TYPE( steemit::chain::category_object, steemit::chain::category_index )
8 changes: 4 additions & 4 deletions libraries/chain/include/steemit/chain/database.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#include <steemit/protocol/protocol.hpp>

#include <graphene/db2/database.hpp>
//#include <graphene/db2/database.hpp>
#include <fc/signals.hpp>

#include <fc/log/logger.hpp>
Expand All @@ -34,7 +34,7 @@ namespace steemit { namespace chain {
* @class database
* @brief tracks the blockchain state in an extensible manner
*/
class database : public graphene::db2::database
class database : public chainbase::database
{
public:
database();
Expand Down Expand Up @@ -232,7 +232,7 @@ namespace steemit { namespace chain {
* Emitted After a block has been applied and committed. The callback
* should not yield and should execute quickly.
*/
fc::signal<void(const vector< graphene::db2::generic_id >&)> changed_objects;
//fc::signal<void(const vector< graphene::db2::generic_id >&)> changed_objects;

/** this signal is emitted any time an object is removed and contains a
* pointer to the last value of every object that was removed.
Expand Down Expand Up @@ -414,7 +414,7 @@ namespace steemit { namespace chain {
void notify_changed_objects();

private:
optional< graphene::db2::database::session > _pending_tx_session;
optional< chainbase::database::session > _pending_tx_session;

void apply_block( const signed_block& next_block, uint32_t skip = skip_nothing );
void apply_transaction( const signed_transaction& trx, uint32_t skip = skip_nothing );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,4 +176,4 @@ FC_REFLECT( steemit::chain::dynamic_global_property_object,
(current_reserve_ratio)
(vote_regeneration_per_day)
)
SET_INDEX_TYPE( steemit::chain::dynamic_global_property_object, steemit::chain::dynamic_global_property_index )
CHAINBASE_SET_INDEX_TYPE( steemit::chain::dynamic_global_property_object, steemit::chain::dynamic_global_property_index )
4 changes: 2 additions & 2 deletions libraries/chain/include/steemit/chain/history_object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ namespace steemit { namespace chain {
} }

FC_REFLECT( steemit::chain::operation_object, (id)(trx_id)(block)(trx_in_block)(op_in_trx)(virtual_op)(timestamp)(serialized_op) )
SET_INDEX_TYPE( steemit::chain::operation_object, steemit::chain::operation_index )
CHAINBASE_SET_INDEX_TYPE( steemit::chain::operation_object, steemit::chain::operation_index )

FC_REFLECT( steemit::chain::account_history_object, (id)(account)(sequence)(op) )
SET_INDEX_TYPE( steemit::chain::account_history_object, steemit::chain::account_history_index )
CHAINBASE_SET_INDEX_TYPE( steemit::chain::account_history_object, steemit::chain::account_history_index )
Loading

0 comments on commit 160bc44

Please sign in to comment.