Skip to content

Commit

Permalink
Merge branch '54-witness-version' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Vandeberg committed May 23, 2016
2 parents f4432a8 + dcd279a commit e8ec57e
Show file tree
Hide file tree
Showing 33 changed files with 790 additions and 197 deletions.
21 changes: 20 additions & 1 deletion libraries/app/database_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,25 @@ dynamic_global_property_object database_api_impl::get_dynamic_global_properties(
return _db.get(dynamic_global_property_id_type());
}

witness_schedule_object database_api::get_witness_schedule()const
{
return witness_schedule_id_type()( my->_db );
}

hardfork_version database_api::get_hardfork_version()const
{
return hardfork_property_id_type()( my->_db ).current_hardfork_version;
}

scheduled_hardfork database_api::get_next_scheduled_hardfork() const
{
scheduled_hardfork shf;
const auto& hpo = hardfork_property_id_type()( my->_db );
shf.hf_version = hpo.next_hardfork;
shf.live_time = hpo.next_hardfork_time;
return shf;
}

//////////////////////////////////////////////////////////////////////
// //
// Keys //
Expand Down Expand Up @@ -1537,7 +1556,7 @@ state database_api::get_state( string path )const
_state.witness_schedule = my->_db.get_witness_schedule_object();

} catch ( const fc::exception& e ) {
_state.error = e.to_detail_string();
_state.error = e.to_detail_string();
}
return _state;
}
Expand Down
41 changes: 28 additions & 13 deletions libraries/app/include/steemit/app/database_api.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,23 @@ struct order_book
};

struct api_context;

struct scheduled_hardfork
{
hardfork_version hf_version;
fc::time_point_sec live_time;
};


class database_api_impl;

/**
* Defines the arguments to a query as a struct so it can be easily extended
*/
struct discussion_query {
void validate()const{
FC_ASSERT( filter_tags.find(tag) == filter_tags.end() );
FC_ASSERT( tag.size() );
void validate()const{
FC_ASSERT( filter_tags.find(tag) == filter_tags.end() );
FC_ASSERT( tag.size() );
FC_ASSERT( limit <= 100 );
}

Expand Down Expand Up @@ -138,6 +146,9 @@ class database_api
chain_properties get_chain_properties()const;
price get_current_median_history_price()const;
feed_history_object get_feed_history()const;
witness_schedule_object get_witness_schedule()const;
hardfork_version get_hardfork_version()const;
scheduled_hardfork get_next_scheduled_hardfork()const;

//////////
// Keys //
Expand Down Expand Up @@ -273,13 +284,13 @@ class database_api
vector<discussion> get_content_replies( string parent, string parent_permlink )const;

///@{ tags API
vector<discussion> get_discussions_by_trending( const discussion_query& query )const;
vector<discussion> get_discussions_by_created( const discussion_query& query )const;
vector<discussion> get_discussions_by_active( const discussion_query& query )const;
vector<discussion> get_discussions_by_cashout( const discussion_query& query )const;
vector<discussion> get_discussions_by_payout( const discussion_query& query )const;
vector<discussion> get_discussions_by_votes( const discussion_query& query )const;
vector<discussion> get_discussions_by_children( const discussion_query& query )const;
vector<discussion> get_discussions_by_trending( const discussion_query& query )const;
vector<discussion> get_discussions_by_created( const discussion_query& query )const;
vector<discussion> get_discussions_by_active( const discussion_query& query )const;
vector<discussion> get_discussions_by_cashout( const discussion_query& query )const;
vector<discussion> get_discussions_by_payout( const discussion_query& query )const;
vector<discussion> get_discussions_by_votes( const discussion_query& query )const;
vector<discussion> get_discussions_by_children( const discussion_query& query )const;

///@}

Expand All @@ -302,7 +313,7 @@ class database_api
*
*/
///@{



/**
Expand Down Expand Up @@ -349,8 +360,8 @@ class database_api
discussion get_discussion( comment_id_type )const;

template<typename Index, typename StartItr>
vector<discussion> get_discussions( const discussion_query& q,
const string& tag,
vector<discussion> get_discussions( const discussion_query& q,
const string& tag,
comment_id_type parent,
const Index& idx, StartItr itr )const;
comment_id_type get_parent( const discussion_query& q )const;
Expand All @@ -363,6 +374,7 @@ class database_api

FC_REFLECT( steemit::app::order, (order_price)(steem)(sbd)(created) );
FC_REFLECT( steemit::app::order_book, (asks)(bids) );
FC_REFLECT( steemit::app::scheduled_hardfork, (hf_version)(live_time) );

FC_REFLECT( steemit::app::discussion_query, (tag)(filter_tags)(start_author)(start_permlink)(parent_author)(parent_permlink)(limit) );

Expand Down Expand Up @@ -398,6 +410,9 @@ FC_API(steemit::app::database_api,
(get_chain_properties)
(get_feed_history)
(get_current_median_history_price)
(get_witness_schedule)
(get_hardfork_version)
(get_next_scheduled_hardfork)

// Keys
(get_key_references)
Expand Down
1 change: 1 addition & 0 deletions libraries/chain/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ add_library( steemit_chain
protocol/transaction.cpp
protocol/block.cpp
protocol/asset.cpp
protocol/version.cpp

get_config.cpp

Expand Down
Loading

0 comments on commit e8ec57e

Please sign in to comment.