Scorum
scorum_api_objects.cpp
Go to the documentation of this file.
2 
5 
7 
8 namespace scorum {
9 namespace app {
10 
11 advertising_property_api_obj::advertising_property_api_obj(const chain::advertising_property_object& obj)
12  : moderator(obj.moderator)
13 {
14  std::copy(std::begin(obj.auction_post_coefficients), std::end(obj.auction_post_coefficients),
15  std::back_inserter(auction_post_coefficients));
16  std::copy(std::begin(obj.auction_banner_coefficients), std::end(obj.auction_banner_coefficients),
17  std::back_inserter(auction_banner_coefficients));
18 }
19 
20 account_api_obj::account_api_obj(const chain::account_object& a, const chain::database& db)
21 {
22  set_account(a);
23  dbs_account_blogging_statistic& account_blogging_statistic_service
25  const auto* pstat = account_blogging_statistic_service.find(a.id);
26  if (pstat)
27  {
28  set_account_blogging_statistic(*pstat);
29  }
30  initialize(a, db);
31 }
32 
33 void account_api_obj::set_account(const chain::account_object& a)
34 {
35  id = a.id;
36  name = a.name;
37  memo_key = a.memo_key;
38  json_metadata = fc::to_string(a.json_metadata);
39  proxy = a.proxy;
40  last_account_update = a.last_account_update;
41  created = a.created;
42  created_by_genesis = a.created_by_genesis;
43  owner_challenged = a.owner_challenged;
44  active_challenged = a.active_challenged;
45  last_owner_proved = a.last_owner_proved;
46  last_active_proved = a.last_active_proved;
47  recovery_account = a.recovery_account;
48  last_account_recovery = a.last_account_recovery;
49  can_vote = a.can_vote;
50  voting_power = a.voting_power;
51  last_vote_time = a.last_vote_time;
52  balance = a.balance;
53  scorumpower = a.scorumpower;
54  delegated_scorumpower = a.delegated_scorumpower;
55  received_scorumpower = a.received_scorumpower;
56  witnesses_voted_for = a.witnesses_voted_for;
57  last_post = a.last_post;
58  last_root_post = a.last_root_post;
59  active_sp_holders_cashout_time = a.active_sp_holders_cashout_time;
60  active_sp_holders_pending_scr_reward = a.active_sp_holders_pending_scr_reward;
61  active_sp_holders_pending_sp_reward = a.active_sp_holders_pending_sp_reward;
62  nft_spend_scorumpower = a.nft_spend_scorumpower;
63 }
64 
65 void account_api_obj::set_account_blogging_statistic(const chain::account_blogging_statistic_object& s)
66 {
67  post_count = s.post_count;
68  comment_count = s.comment_count;
69  vote_count = s.vote_count;
70  curation_rewards_scr = s.curation_rewards_scr;
71  curation_rewards_sp = s.curation_rewards_sp;
72  posting_rewards_scr = s.posting_rewards_scr;
73  posting_rewards_sp = s.posting_rewards_sp;
74 }
75 
76 void account_api_obj::initialize(const chain::account_object& a, const chain::database& db)
77 {
78  size_t n = a.proxied_vsf_votes.size();
79  proxied_vsf_votes.reserve(n);
80  for (size_t i = 0; i < n; i++)
81  proxied_vsf_votes.push_back(a.proxied_vsf_votes[i]);
82 
83  const auto& auth = db.get<account_authority_object, by_account>(name);
84  owner = authority(auth.owner);
85  active = authority(auth.active);
86  posting = authority(auth.posting);
87  last_owner_update = auth.last_owner_update;
88 
89  if (db.has_index<witness::account_bandwidth_index>())
90  {
91  auto forum_bandwidth = db.find<witness::account_bandwidth_object, witness::by_account_bandwidth_type>(
92  boost::make_tuple(name, witness::bandwidth_type::forum));
93 
94  if (forum_bandwidth != nullptr)
95  {
96  average_bandwidth = forum_bandwidth->average_bandwidth;
97  lifetime_bandwidth = forum_bandwidth->lifetime_bandwidth;
98  last_bandwidth_update = forum_bandwidth->last_bandwidth_update;
99  }
100 
101  auto market_bandwidth = db.find<witness::account_bandwidth_object, witness::by_account_bandwidth_type>(
102  boost::make_tuple(name, witness::bandwidth_type::market));
103 
104  if (market_bandwidth != nullptr)
105  {
106  average_market_bandwidth = market_bandwidth->average_bandwidth;
107  lifetime_market_bandwidth = market_bandwidth->lifetime_bandwidth;
108  last_market_bandwidth_update = market_bandwidth->last_bandwidth_update;
109  }
110  }
111 }
112 } // namespace app
113 } // namespace scorum
tracks the blockchain state in an extensible manner
Definition: database.hpp:52
const account_blogging_statistic_object * find(const account_id_type &account_id) const override
@ market
Rate limiting for all other actions.
@ forum
Rate limiting for all forum related actions.
shared_multi_index_container< account_bandwidth_object, indexed_by< ordered_unique< tag< by_id >, member< account_bandwidth_object, account_bandwidth_id_type, &account_bandwidth_object::id > >, ordered_unique< tag< by_account_bandwidth_type >, composite_key< account_bandwidth_object, member< account_bandwidth_object, account_name_type, &account_bandwidth_object::account >, member< account_bandwidth_object, bandwidth_type, &account_bandwidth_object::type > > > > > account_bandwidth_index
Definition: asset.cpp:15
std::vector< share_type > proxied_vsf_votes
std::vector< percent_type > auction_banner_coefficients
std::vector< percent_type > auction_post_coefficients