Skip to content

Commit

Permalink
Fix condenser_api.get_witnesses_by_vote #2126
Browse files Browse the repository at this point in the history
  • Loading branch information
mvandeberg committed Feb 15, 2018
1 parent 301b44e commit aabe347
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 @@ -1136,16 +1136,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 aabe347

Please sign in to comment.