Scorum
proposal_vote_evaluator.cpp
Go to the documentation of this file.
2 
4 
6 
14 
15 namespace scorum {
16 namespace chain {
17 
18 proposal_vote_evaluator::proposal_vote_evaluator(data_service_factory_i& services)
19  : evaluator_impl<data_service_factory_i, proposal_vote_evaluator>(services)
20  , _account_service(db().account_service())
21  , _proposal_service(db().proposal_service())
22  , _properties_service(db().dynamic_global_property_service())
23  , _proposal_executor(db().proposal_executor_service())
24 {
25 }
26 
28 {
29  FC_ASSERT(_proposal_service.is_exists(op.proposal_id), "There is no proposal with id '${id}'",
30  ("id", op.proposal_id));
31 
32  const proposal_object& proposal = _proposal_service.get(op.proposal_id);
33 
35 
37  "Account \"${account_name}\" is not in committee.", ("account_name", op.voting_account));
38 
39  _account_service.check_account_existence(op.voting_account);
40 
41  FC_ASSERT(proposal.voted_accounts.find(op.voting_account) == proposal.voted_accounts.end(),
42  "Account \"${account}\" already voted", ("account", op.voting_account));
43 
44  FC_ASSERT(!_proposal_service.is_expired(proposal), "Proposal '${id}' is expired.", ("id", op.proposal_id));
45 
46  _proposal_service.vote_for(op.voting_account, proposal);
47 
48  _proposal_executor(proposal);
49 }
50 
51 } // namespace chain
52 } // namespace scorum
proposal_vote_evaluator(data_service_factory_i &services)
signed_transaction proposal(const std::string &initiator, uint32_t lifetime_sec, C &&constructor)
Definition: wallet.cpp:2754
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 void vote_for(const account_name_type &voter, const proposal_object &proposal)=0
virtual bool is_exists(proposal_id_type proposal_id)=0
virtual bool is_expired(const proposal_object &proposal)=0
virtual const proposal_object & get(proposal_id_type proposal_id)=0
virtual bool is_exists(const account_name_type &) const =0
std::vector< typename Visitor::result_type > visit(Visitor &&visitor)
Definition: transaction.hpp:29