Scorum
process_fifa_world_cup_2018_bounty_cashout.cpp
Go to the documentation of this file.
2 
4 
5 namespace scorum {
6 namespace chain {
7 namespace database_ns {
8 
10 {
11  debug_log(ctx.get_block_info(), "process_fifa_world_cup_2018_bounty_cashout BEGIN");
12 
13  dynamic_global_property_service_i& dprops_service = ctx.services().dynamic_global_property_service();
14 
15  if (dprops_service.head_block_time() < SCORUM_FIFA_WORLD_CUP_2018_BOUNTY_CASHOUT_DATE)
16  {
17  return;
18  }
19 
20  auto& fifa_world_cup_2018_bounty_reward_fund_service
21  = ctx.services().content_fifa_world_cup_2018_bounty_reward_fund_service();
22 
23  if (!fifa_world_cup_2018_bounty_reward_fund_service.is_exists())
24  {
25  return;
26  }
27 
29  = fifa_world_cup_2018_bounty_reward_fund_service.get();
30 
31  if (bounty_fund.activity_reward_balance.amount < 1)
32  {
33  return;
34  }
35 
36  comment_service_i& comment_service = ctx.services().comment_service();
37 
38  const auto fn_filter
39  = [&](const comment_object& c) { return c.net_rshares > 0 && c.cashout_time == fc::time_point_sec::maximum(); };
40  auto comments = comment_service.get_by_create_time(SCORUM_FIFA_WORLD_CUP_2018_BOUNTY_CASHOUT_DATE, fn_filter);
41 
43 
44  impl.reward(fifa_world_cup_2018_bounty_reward_fund_service, comments);
45 
46  auto balance = bounty_fund.activity_reward_balance;
47 
48  if (balance.amount > 0 && !comments.empty())
49  {
50  wlog("There is precision remainder = ${r}", ("r", balance));
51 
52  // distribute precision remainder
53  // that is not distributed by default process comments cashout algorithm
54 
55  const auto& oldest_comment = comments[0];
56 
57  impl.pay_for_comment_legacy(oldest_comment, balance, asset(0, balance.symbol()));
58 
59  fifa_world_cup_2018_bounty_reward_fund_service.update([&](
61  }
62  else if (balance.amount > 0)
63  {
64  wlog("Fund ${a} is not distributed", ("a", balance));
65 
66  content_reward_fund_sp_service_i& reward_fund_service = ctx.services().content_reward_fund_sp_service();
67 
68  fifa_world_cup_2018_bounty_reward_fund_service.update([&](
70 
71  reward_fund_service.update([&](content_reward_fund_sp_object& rfo) { rfo.activity_reward_balance += balance; });
72  }
73 
74  debug_log(ctx.get_block_info(), "process_fifa_world_cup_2018_bounty_cashout END");
75 }
76 }
77 }
78 }
data_service_factory_i & services() const
Definition: block_tasks.hpp:25
comment_payout_result pay_for_comment_legacy(const comment_object &comment, const asset &publication_reward, const asset &parent_payout_value)
void reward(TFundService &fund_service, const comment_refs_type &comments)
#define debug_log(CTX, FORMAT,...)
Definition: debug_log.hpp:3
Definition: asset.cpp:15
virtual void update(const modifier_type &modifier)=0
virtual comment_refs_type get_by_create_time(const fc::time_point_sec &until, const checker_type &) const =0
virtual fc::time_point_sec head_block_time() const =0
share_type amount
Definition: asset.hpp:31