fetch workers by vote_id
This commit is contained in:
parent
dd7d57c5ac
commit
225acfff25
1 changed files with 18 additions and 1 deletions
|
|
@ -1118,10 +1118,12 @@ vector<variant> database_api::lookup_vote_ids( const vector<vote_id_type>& votes
|
|||
|
||||
vector<variant> database_api_impl::lookup_vote_ids( const vector<vote_id_type>& votes )const
|
||||
{
|
||||
FC_ASSERT( votes.size() < 100, "Only 100 votes can be queried at a time" );
|
||||
FC_ASSERT( votes.size() < 1000, "Only 1000 votes can be queried at a time" );
|
||||
|
||||
const auto& witness_idx = _db.get_index_type<witness_index>().indices().get<by_vote_id>();
|
||||
const auto& committee_idx = _db.get_index_type<committee_member_index>().indices().get<by_vote_id>();
|
||||
const auto& for_worker_idx = _db.get_index_type<worker_index>().indices().get<by_vote_for>();
|
||||
const auto& against_worker_idx = _db.get_index_type<worker_index>().indices().get<by_vote_against>();
|
||||
|
||||
vector<variant> result;
|
||||
result.reserve( votes.size() );
|
||||
|
|
@ -1148,7 +1150,22 @@ vector<variant> database_api_impl::lookup_vote_ids( const vector<vote_id_type>&
|
|||
break;
|
||||
}
|
||||
case vote_id_type::worker:
|
||||
{
|
||||
auto itr = for_worker_idx.find( id );
|
||||
if( itr != for_worker_idx.end() ) {
|
||||
result.emplace_back( variant( *itr ) );
|
||||
}
|
||||
else {
|
||||
auto itr = against_worker_idx.find( id );
|
||||
if( itr != against_worker_idx.end() ) {
|
||||
result.emplace_back( variant( *itr ) );
|
||||
}
|
||||
else {
|
||||
result.emplace_back( variant() );
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case vote_id_type::VOTE_TYPE_COUNT: break; // supress unused enum value warnings
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue