Code formatting
This commit is contained in:
parent
050c0b27e5
commit
8be4dd5e3c
2 changed files with 90 additions and 106 deletions
|
|
@ -53,26 +53,18 @@ template class fc::api<graphene::app::database_api>;
|
||||||
namespace graphene { namespace app {
|
namespace graphene { namespace app {
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
optional<T> maybe_id( const string& name_or_id )
|
optional<T> maybe_id(const string &name_or_id) {
|
||||||
{
|
if (std::isdigit(name_or_id.front())) {
|
||||||
if( std::isdigit( name_or_id.front() ) )
|
try {
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return fc::variant(name_or_id, 1).as<T>(1);
|
return fc::variant(name_or_id, 1).as<T>(1);
|
||||||
}
|
} catch (const fc::exception &) { // not an ID
|
||||||
catch (const fc::exception&)
|
|
||||||
{ // not an ID
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return optional<T>();
|
return optional<T>();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string object_id_to_string(object_id_type id)
|
std::string object_id_to_string(object_id_type id) {
|
||||||
{
|
std::string object_id = fc::to_string(id.space()) + "." + fc::to_string(id.type()) + "." + fc::to_string(id.instance());
|
||||||
std::string object_id = fc::to_string(id.space())
|
|
||||||
+ "." + fc::to_string(id.type())
|
|
||||||
+ "." + fc::to_string(id.instance());
|
|
||||||
return object_id;
|
return object_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -212,8 +204,7 @@ public:
|
||||||
vector<variant> lookup_vote_ids(const vector<vote_id_type> &votes) const;
|
vector<variant> lookup_vote_ids(const vector<vote_id_type> &votes) const;
|
||||||
vector<vote_id_type> get_votes_ids(const string &account_name_or_id) const;
|
vector<vote_id_type> get_votes_ids(const string &account_name_or_id) const;
|
||||||
template <typename IndexType, typename Tag>
|
template <typename IndexType, typename Tag>
|
||||||
vector<variant> get_votes_objects(const vector<vote_id_type> &votes, unsigned int variant_max_depth = 1) const
|
vector<variant> get_votes_objects(const vector<vote_id_type> &votes, unsigned int variant_max_depth = 1) const {
|
||||||
{
|
|
||||||
static_assert(std::is_base_of<index, IndexType>::value, "Type must be an index type");
|
static_assert(std::is_base_of<index, IndexType>::value, "Type must be an index type");
|
||||||
|
|
||||||
vector<variant> result;
|
vector<variant> result;
|
||||||
|
|
@ -2129,8 +2120,7 @@ vector<vote_id_type> database_api_impl::get_votes_ids(const string &account_name
|
||||||
const account_object *account = get_account_from_string(account_name_or_id);
|
const account_object *account = get_account_from_string(account_name_or_id);
|
||||||
|
|
||||||
//! Iterate throug votes and fill vector
|
//! Iterate throug votes and fill vector
|
||||||
for( const auto& vote : account->options.votes )
|
for (const auto &vote : account->options.votes) {
|
||||||
{
|
|
||||||
result.emplace_back(vote);
|
result.emplace_back(vote);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2206,8 +2196,7 @@ vector<account_object> database_api_impl::get_voters_by_id(const vote_id_type &v
|
||||||
|
|
||||||
//! We search all accounts that have voted for this vote_id
|
//! We search all accounts that have voted for this vote_id
|
||||||
const auto &account_index = _db.get_index_type<graphene::chain::account_index>().indices().get<by_id>();
|
const auto &account_index = _db.get_index_type<graphene::chain::account_index>().indices().get<by_id>();
|
||||||
for( const auto& account: account_index )
|
for (const auto &account : account_index) {
|
||||||
{
|
|
||||||
if (account.options.votes.count(vote_id) != 0)
|
if (account.options.votes.count(vote_id) != 0)
|
||||||
result.emplace_back(account);
|
result.emplace_back(account);
|
||||||
}
|
}
|
||||||
|
|
@ -2228,8 +2217,7 @@ voters_info database_api_impl::get_voters(const string &account_name_or_id) cons
|
||||||
//! It is account
|
//! It is account
|
||||||
owner_account_id = object_id_to_string(account_object->get_id());
|
owner_account_id = object_id_to_string(account_object->get_id());
|
||||||
owner_account_found = true;
|
owner_account_found = true;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
//! Check if we have account id
|
//! Check if we have account id
|
||||||
const auto &account_id = maybe_id<account_id_type>(account_name_or_id);
|
const auto &account_id = maybe_id<account_id_type>(account_name_or_id);
|
||||||
if (account_id) {
|
if (account_id) {
|
||||||
|
|
@ -2243,8 +2231,7 @@ voters_info database_api_impl::get_voters(const string &account_name_or_id) cons
|
||||||
owner_account_found = true;
|
owner_account_found = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
//! Check if we have committee member id
|
//! Check if we have committee member id
|
||||||
const auto &committee_member_id = maybe_id<committee_member_id_type>(account_name_or_id);
|
const auto &committee_member_id = maybe_id<committee_member_id_type>(account_name_or_id);
|
||||||
if (committee_member_id) {
|
if (committee_member_id) {
|
||||||
|
|
@ -2258,8 +2245,7 @@ voters_info database_api_impl::get_voters(const string &account_name_or_id) cons
|
||||||
owner_account_found = true;
|
owner_account_found = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
//! Check if we have witness id
|
//! Check if we have witness id
|
||||||
const auto &witness_id = maybe_id<witness_id_type>(account_name_or_id);
|
const auto &witness_id = maybe_id<witness_id_type>(account_name_or_id);
|
||||||
if (witness_id) {
|
if (witness_id) {
|
||||||
|
|
@ -2273,8 +2259,7 @@ voters_info database_api_impl::get_voters(const string &account_name_or_id) cons
|
||||||
owner_account_found = true;
|
owner_account_found = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
//! Check if we have worker id
|
//! Check if we have worker id
|
||||||
const auto &worker_id = maybe_id<worker_id_type>(account_name_or_id);
|
const auto &worker_id = maybe_id<worker_id_type>(account_name_or_id);
|
||||||
if (worker_id) {
|
if (worker_id) {
|
||||||
|
|
@ -2288,8 +2273,7 @@ voters_info database_api_impl::get_voters(const string &account_name_or_id) cons
|
||||||
owner_account_found = true;
|
owner_account_found = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
//! Check if we have son id
|
//! Check if we have son id
|
||||||
const auto &son_id = maybe_id<son_id_type>(account_name_or_id);
|
const auto &son_id = maybe_id<son_id_type>(account_name_or_id);
|
||||||
if (son_id) {
|
if (son_id) {
|
||||||
|
|
|
||||||
|
|
@ -56,8 +56,8 @@
|
||||||
#include <graphene/chain/custom_permission_object.hpp>
|
#include <graphene/chain/custom_permission_object.hpp>
|
||||||
#include <graphene/chain/nft_object.hpp>
|
#include <graphene/chain/nft_object.hpp>
|
||||||
#include <graphene/chain/offer_object.hpp>
|
#include <graphene/chain/offer_object.hpp>
|
||||||
#include <graphene/chain/votes_info.hpp>
|
|
||||||
#include <graphene/chain/voters_info.hpp>
|
#include <graphene/chain/voters_info.hpp>
|
||||||
|
#include <graphene/chain/votes_info.hpp>
|
||||||
|
|
||||||
#include <graphene/market_history/market_history_plugin.hpp>
|
#include <graphene/market_history/market_history_plugin.hpp>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue