Scorum
close_budget_evaluator.cpp
Go to the documentation of this file.
2 
4 
8 
12 
13 namespace scorum {
14 namespace chain {
15 
16 close_budget_evaluator::close_budget_evaluator(data_service_factory_i& services)
17  : evaluator_impl<data_service_factory_i, close_budget_evaluator>(services)
18  , _account_service(services.account_service())
19  , _post_budget_service(services.post_budget_service())
20  , _banner_budget_service(services.banner_budget_service())
21 {
22 }
23 
25 {
26  switch (op.type)
27  {
28  case budget_type::post:
29  close_budget(_post_budget_service, op);
30  break;
31  case budget_type::banner:
32  close_budget(_banner_budget_service, op);
33  break;
34  }
35 }
36 
37 template <protocol::budget_type budget_type_v>
38 void close_budget_evaluator::close_budget(adv_budget_service_i<budget_type_v>& budget_svc, const operation_type& op)
39 {
40  _account_service.check_account_existence(op.owner);
41  FC_ASSERT(budget_svc.is_exists(op.uuid), "Budget with uuid ${id} doesn't exist", ("id", op.uuid));
42 
43  const auto& budget = budget_svc.get(op.uuid);
44  FC_ASSERT(budget.owner == op.owner, "These is not [${o}/${id}] budget", ("o", op.owner)("id", op.uuid));
45 
46  budget_svc.finish_budget(op.uuid);
47 }
48 }
49 }
void do_apply(const operation_type &op)
close_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 void finish_budget(const uuid_type &uuid)=0
virtual const adv_budget_object< budget_type_v > & get(const oid< adv_budget_object< budget_type_v >> &) const =0
Closes advertising budget, remaining funds will be returned to creator.