Skip to content

Commit

Permalink
Merge pull request #2128 from steemit/2126-fix-get-witnesses-by-vote
Browse files Browse the repository at this point in the history
Fix condenser_api.get_witnesses_by_vote
  • Loading branch information
Michael Vandeberg authored Feb 16, 2018
2 parents 3cecc12 + aabe347 commit b767197
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions libraries/plugins/apis/condenser_api/condenser_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1138,16 +1138,26 @@ namespace detail
DEFINE_API_IMPL( condenser_api_impl, get_witnesses_by_vote )
{
CHECK_ARG_SIZE( 2 )
auto start = _database_api->list_witnesses( { args[0], 1, database_api::by_name } );
account_name_type start_name = args[0].as< account_name_type >();
vector< fc::variant > start_key;
if( start_name == account_name_type() )
{
start_key.push_back( fc::variant( std::numeric_limits< int64_t >::max() ) );
start_key.push_back( fc::variant( account_name_type() ) );
}
else
{
auto start = _database_api->list_witnesses( { args[0], 1, database_api::by_name } );
if( start.witnesses.size() == 0 )
return get_witnesses_by_vote_return();
if( start.witnesses.size() == 0 )
return get_witnesses_by_vote_return();
auto limit = args[1].as< uint32_t >();
vector< fc::variant > start_key;
start_key.push_back( fc::variant( start.witnesses[0].votes ) );
start_key.push_back( fc::variant( start.witnesses[0].owner ) );
start_key.push_back( fc::variant( start.witnesses[0].votes ) );
start_key.push_back( fc::variant( start.witnesses[0].owner ) );
}
auto limit = args[1].as< uint32_t >();
auto witnesses = _database_api->list_witnesses( { fc::variant( start_key ), limit, database_api::by_vote_name } ).witnesses;
get_witnesses_by_vote_return result;
Expand Down

0 comments on commit b767197

Please sign in to comment.