Scorum
update_budget_evaluator.cpp
Go to the documentation of this file.
2 
4 
7 
10 
11 namespace scorum {
12 namespace chain {
13 
14 update_budget_evaluator::update_budget_evaluator(data_service_factory_i& services)
15  : evaluator_impl<data_service_factory_i, update_budget_evaluator>(services)
16  , _account_service(services.account_service())
17  , _post_budget_service(services.post_budget_service())
18  , _banner_budget_service(services.banner_budget_service())
19 {
20 }
21 
23 {
24  switch (op.type)
25  {
26  case budget_type::post:
27  update_budget(_post_budget_service, op);
28  break;
29  case budget_type::banner:
30  update_budget(_banner_budget_service, op);
31  break;
32  }
33 }
34 
35 template <protocol::budget_type budget_type_v>
36 void update_budget_evaluator::update_budget(adv_budget_service_i<budget_type_v>& budget_svc, const operation_type& op)
37 {
38  _account_service.check_account_existence(op.owner);
39  FC_ASSERT(budget_svc.is_exists(op.uuid), "Budget with id ${id} doesn't exist", ("id", op.uuid));
40 
41  const auto& budget = budget_svc.get(op.uuid);
42  FC_ASSERT(budget.owner == op.owner, "These is not [${o}/${id}] budget", ("o", op.owner)("id", op.uuid));
43 
44 #ifndef IS_LOW_MEM
45  budget_svc.update(budget, [&](auto& b) { fc::from_string(b.json_metadata, op.json_metadata); });
46 #else
47  boost::ignore_unused_variable_warning(budget);
48 #endif
49 }
50 }
51 }
update_budget_evaluator(data_service_factory_i &services)
Definition: asset.cpp:15
virtual void check_account_existence(const account_name_type &, const optional< const char * > &context_type_name=optional< const char * >()) const =0
virtual bool is_exists(const uuid_type &uuid) const =0
virtual const adv_budget_object< budget_type_v > & get(const oid< adv_budget_object< budget_type_v >> &) const =0
virtual void update(const modifier_type &modifier)=0
Updates advertising budget metadata.