Scorum
account_blogging_statistic.cpp
Go to the documentation of this file.
2 
3 namespace scorum {
4 namespace chain {
5 
8 {
9 }
10 
11 const account_blogging_statistic_object& dbs_account_blogging_statistic::obtain(const account_id_type& account_id)
12 {
13  try
14  {
15  if (nullptr == find_by<by_account_id>(account_id))
16  {
17  return create([&](account_blogging_statistic_object& stat) { stat.account = account_id; });
18  }
19  else
20  {
21  return get_by<by_account_id>(account_id);
22  }
23  }
24  FC_CAPTURE_AND_RETHROW((account_id))
25 }
26 
27 const account_blogging_statistic_object* dbs_account_blogging_statistic::find(const account_id_type& account_id) const
28 {
29  return find_by<by_account_id>(account_id);
30 }
31 
32 void dbs_account_blogging_statistic::add_post(const account_blogging_statistic_object& stat)
33 {
34  update(stat, [&](account_blogging_statistic_object& a) { a.post_count++; });
35 }
36 
37 void dbs_account_blogging_statistic::add_comment(const account_blogging_statistic_object& stat)
38 {
39  update(stat, [&](account_blogging_statistic_object& a) { a.comment_count++; });
40 }
41 
42 void dbs_account_blogging_statistic::add_vote(const account_blogging_statistic_object& stat)
43 {
44  update(stat, [&](account_blogging_statistic_object& a) { a.vote_count++; });
45 }
46 
47 void dbs_account_blogging_statistic::increase_posting_rewards(const account_blogging_statistic_object& stat,
48  const asset& reward)
49 {
50  if (SCORUM_SYMBOL == reward.symbol())
51  {
52  update(stat, [&](account_blogging_statistic_object& a) { a.posting_rewards_scr += reward; });
53  }
54  else if (SP_SYMBOL == reward.symbol())
55  {
56  update(stat, [&](account_blogging_statistic_object& a) { a.posting_rewards_sp += reward; });
57  }
58 }
59 
60 void dbs_account_blogging_statistic::increase_curation_rewards(const account_blogging_statistic_object& stat,
61  const asset& reward)
62 {
63  if (SCORUM_SYMBOL == reward.symbol())
64  {
65  update(stat, [&](account_blogging_statistic_object& a) { a.curation_rewards_scr += reward; });
66  }
67  else if (SP_SYMBOL == reward.symbol())
68  {
69  update(stat, [&](account_blogging_statistic_object& a) { a.curation_rewards_sp += reward; });
70  }
71 }
72 }
73 }
tracks the blockchain state in an extensible manner
Definition: database.hpp:52
void increase_posting_rewards(const account_blogging_statistic_object &stat, const asset &amount) override
void add_post(const account_blogging_statistic_object &stat) override
void add_vote(const account_blogging_statistic_object &stat) override
const account_blogging_statistic_object & obtain(const account_id_type &account_id) override
const account_blogging_statistic_object * find(const account_id_type &account_id) const override
void increase_curation_rewards(const account_blogging_statistic_object &stat, const asset &amount) override
void add_comment(const account_blogging_statistic_object &stat) override
virtual const object_type & create(const modifier_type &modifier) override
virtual void update(const modifier_type &modifier) override
#define SP_SYMBOL
Definition: config.hpp:104
#define SCORUM_SYMBOL
Definition: config.hpp:102
Definition: asset.cpp:15
asset_symbol_type symbol() const
Definition: asset.hpp:32