Skip to content

Commit

Permalink
some work toward fixed sized memory and memory mapped files
Browse files Browse the repository at this point in the history
  • Loading branch information
revflash committed Sep 15, 2016
1 parent 40f9f01 commit 6b593c2
Show file tree
Hide file tree
Showing 27 changed files with 356 additions and 372 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ else( WIN32 ) # Apple AND Linux
if( APPLE )
# Apple Specific Options Here
message( STATUS "Configuring Steem on OS X" )
set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -std=c++11 -stdlib=libc++ -Wall -Wno-conversion" )
set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -std=c++11 -stdlib=libc++ -Wall -Wno-conversion -Wno-deprecated-declarations" )
else( APPLE )
# Linux Specific Options Here
message( STATUS "Configuring Steem on Linux" )
Expand Down
28 changes: 19 additions & 9 deletions libraries/app/database_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class database_api_impl : public std::enable_shared_from_this<database_api_impl>
// Witnesses
vector<optional<witness_object>> get_witnesses(const vector<witness_id_type>& witness_ids)const;
fc::optional<witness_object> get_witness_by_account( string account_name )const;
set<string> lookup_witness_accounts(const string& lower_bound_name, uint32_t limit)const;
set<account_name_type> lookup_witness_accounts(const string& lower_bound_name, uint32_t limit)const;
uint64_t get_witness_count()const;

// Market
Expand Down Expand Up @@ -581,20 +581,20 @@ fc::optional<witness_object> database_api_impl::get_witness_by_account( string a
return {};
}

set< string > database_api::lookup_witness_accounts( const string& lower_bound_name, uint32_t limit ) const
set< account_name_type > database_api::lookup_witness_accounts( const string& lower_bound_name, uint32_t limit ) const
{
return my->lookup_witness_accounts( lower_bound_name, limit );
}

set< string > database_api_impl::lookup_witness_accounts( const string& lower_bound_name, uint32_t limit ) const
set< account_name_type > database_api_impl::lookup_witness_accounts( const string& lower_bound_name, uint32_t limit ) const
{
FC_ASSERT( limit <= 1000 );
const auto& witnesses_by_id = _db.get_index_type< witness_index >().indices().get< by_id >();

// get all the names and look them all up, sort them, then figure out what
// records to return. This could be optimized, but we expect the
// number of witnesses to be few and the frequency of calls to be rare
set< std::string > witnesses_by_account_name;
set< account_name_type > witnesses_by_account_name;
for ( const witness_object& witness : witnesses_by_id )
if ( witness.owner >= lower_bound_name ) // we can ignore anything below lower_bound_name
witnesses_by_account_name.insert( witness.owner );
Expand Down Expand Up @@ -843,7 +843,7 @@ bool database_api_impl::verify_account_authority( const string& name_or_id, cons
/// reuse trx.verify_authority by creating a dummy transfer
signed_transaction trx;
transfer_operation op;
op.from = account->id;
op.from = account->name;
trx.operations.emplace_back(op);

return verify_authority( trx );
Expand Down Expand Up @@ -1013,6 +1013,8 @@ vector<discussion> database_api::get_content_replies( string author, string perm
vector<discussion> database_api::get_replies_by_last_update( string start_parent_author, string start_permlink, uint32_t limit )const {

// idump((start_parent_author)(start_permlink)(limit) );
vector<discussion> result;
/*
const auto& last_update_idx = my->_db.get_index_type< comment_index >().indices().get< by_last_update >();
auto itr = last_update_idx.begin();
Expand All @@ -1026,7 +1028,6 @@ vector<discussion> database_api::get_replies_by_last_update( string start_parent
filter_by_parent_author = true;
}
vector<discussion> result;
while( itr != last_update_idx.end() && result.size() < limit ) {
if( filter_by_parent_author && itr->parent_author != start_parent_author ) {
return result;
Expand All @@ -1037,6 +1038,7 @@ vector<discussion> database_api::get_replies_by_last_update( string start_parent
result.back().active_votes = get_active_votes( itr->author, itr->permlink );
++itr;
}
*/
return result;
}

Expand Down Expand Up @@ -1353,8 +1355,8 @@ void database_api::recursively_fetch_content( state& _state, discussion& root, s
}
} FC_CAPTURE_AND_RETHROW( (root.author)(root.permlink) ) }

vector<string> database_api::get_miner_queue()const {
vector<string> result;
vector<account_name_type> database_api::get_miner_queue()const {
vector<account_name_type> result;
const auto& pow_idx = my->_db.get_index_type<witness_index>().indices().get<by_pow>();

auto itr = pow_idx.upper_bound(0);
Expand All @@ -1366,7 +1368,7 @@ vector<string> database_api::get_miner_queue()const {
return result;
}

vector<string> database_api::get_active_witnesses()const {
vector<account_name_type> database_api::get_active_witnesses()const {
const auto& wso = my->_db.get_witness_schedule_object();
return wso.current_shuffled_witnesses;
}
Expand All @@ -1378,6 +1380,7 @@ vector<discussion> database_api::get_discussions_by_author_before_date(
{
vector<discussion> result;

/*
FC_ASSERT( limit <= 100 );
result.reserve( limit );
int count = 0;
Expand Down Expand Up @@ -1406,6 +1409,7 @@ vector<discussion> database_api::get_discussions_by_author_before_date(
}
++itr;
}
*/

return result;
}
Expand Down Expand Up @@ -1518,6 +1522,7 @@ state database_api::get_state( string path )const
}
}
} else if( part[1] == "recent-replies" ) {
/*
auto replies = get_replies_by_last_update( acnt, "", 50 );
eacnt.recent_replies = vector<string>();
for( const auto& reply : replies ) {
Expand All @@ -1529,7 +1534,9 @@ state database_api::get_state( string path )const
}
eacnt.recent_replies->push_back( reply_ref );
}
*/
} else if( part[1] == "posts" ) {
/*
int count = 0;
const auto& pidx = my->_db.get_index_type<comment_index>().indices().get<by_author_last_update>();
auto itr = pidx.lower_bound( boost::make_tuple(acnt, time_point_sec::maximum() ) );
Expand All @@ -1541,7 +1548,9 @@ state database_api::get_state( string path )const
++itr;
++count;
}
*/
} else if( part[1].size() == 0 || part[1] == "blog" ) {
/*
int count = 0;
const auto& pidx = my->_db.get_index_type<comment_index>().indices().get<by_blog>();
auto itr = pidx.lower_bound( boost::make_tuple(acnt, std::string(""), time_point_sec::maximum() ) );
Expand All @@ -1553,6 +1562,7 @@ state database_api::get_state( string path )const
++itr;
++count;
}
*/
} else if( part[1].size() == 0 || part[1] == "feed" )
{
if( my->_follow_api )
Expand Down
2 changes: 1 addition & 1 deletion libraries/app/impacted.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ struct get_impacted_account_visitor
{
_impacted.insert( op.from );

if ( !op.to.empty() && op.to != op.from )
if ( op.to != account_name_type() && op.to != op.from )
{
_impacted.insert( op.to );
}
Expand Down
6 changes: 3 additions & 3 deletions libraries/app/include/steemit/app/database_api.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ class database_api
vector<category_object> get_active_categories( string after, uint32_t limit )const;
vector<category_object> get_recent_categories( string after, uint32_t limit )const;

vector<string> get_active_witnesses()const;
vector<string> get_miner_queue()const;
vector<account_name_type> get_active_witnesses()const;
vector<account_name_type> get_miner_queue()const;

/////////////////////////////
// Blocks and transactions //
Expand Down Expand Up @@ -255,7 +255,7 @@ class database_api
* @param limit Maximum number of results to return -- must not exceed 1000
* @return Map of witness names to corresponding IDs
*/
set<string> lookup_witness_accounts(const string& lower_bound_name, uint32_t limit)const;
set<account_name_type> lookup_witness_accounts(const string& lower_bound_name, uint32_t limit)const;

/**
* @brief Get the total number of witnesses registered with the blockchain
Expand Down
2 changes: 1 addition & 1 deletion libraries/app/include/steemit/app/state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ namespace steemit { namespace app {
/**
* The list of miners who are queued to produce work
*/
vector<string> pow_queue;
vector<account_name_type> pow_queue;
map<string, witness_object> witnesses;
witness_schedule_object witness_schedule;
price feed_price;
Expand Down
6 changes: 4 additions & 2 deletions libraries/chain/block_database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,13 @@ optional<signed_block> block_database::fetch_by_number( uint32_t block_num )cons
FC_ASSERT( result.id() == e.block_id );
return result;
}
catch (const fc::exception&)
catch (const fc::exception& e)
{
idump((e.to_detail_string()));
}
catch (const std::exception&)
catch (const std::exception& e)
{
idump((e.what()));
}
return optional<signed_block>();
}
Expand Down
Loading

0 comments on commit 6b593c2

Please sign in to comment.