Scorum
withdraw_scorumpower.cpp
Go to the documentation of this file.
2 
4 
6 
7 namespace scorum {
8 namespace chain {
9 
11  : base_service_type(db)
12 {
13 }
14 
16 {
17 }
18 
20 {
21  return find_by<by_destination>(from) != nullptr;
22 }
23 
25 {
26  return find_by<by_destination>(from) != nullptr;
27 }
28 
30 {
31  try
32  {
33  return get_by<by_destination>(from);
34  }
35  FC_CAPTURE_AND_RETHROW((from))
36 }
37 
39 {
40  try
41  {
42  return get_by<by_destination>(from);
43  }
44  FC_CAPTURE_AND_RETHROW((from))
45 }
46 
48 dbs_withdraw_scorumpower::get_until(const time_point_sec& until) const
49 {
51 
52  const auto& idx = db_impl().get_index<withdraw_scorumpower_index>().indices().get<by_next_vesting_withdrawal>();
53  auto it = idx.cbegin();
54  const auto it_end = idx.cend();
55  while (it != it_end && it->next_vesting_withdrawal <= until)
56  {
57  ret.push_back(std::cref(*it));
58  ++it;
59  }
60 
61  return ret;
62 }
63 
65 {
66  if (!is_exists(from))
67  return asset(0, SP_SYMBOL);
68  const withdraw_scorumpower_object& wvo = get(from);
69  return wvo.to_withdraw - wvo.withdrawn;
70 }
71 
72 } // namespace chain
73 } // namespace scorum
tracks the blockchain state in an extensible manner
Definition: database.hpp:52
dba::db_index & db_impl()
Definition: dbs_base.cpp:22
virtual const object_type & get() const override
virtual withdraw_scorumpower_refs_type get_until(const time_point_sec &until) const override
virtual asset get_withdraw_rest(const account_id_type &from) const override
asset to_withdraw
Track how many shares have been withdrawn.
#define SP_SYMBOL
Definition: config.hpp:104
shared_multi_index_container< withdraw_scorumpower_object, indexed_by< ordered_unique< tag< by_id >, member< withdraw_scorumpower_object, withdraw_scorumpower_id_type, &withdraw_scorumpower_object::id > >, ordered_unique< tag< by_destination >, member< withdraw_scorumpower_object, withdrawable_id_type, &withdraw_scorumpower_object::from_id >, less_for_withdrawable_id >, ordered_unique< tag< by_next_vesting_withdrawal >, composite_key< withdraw_scorumpower_object, member< withdraw_scorumpower_object, time_point_sec, &withdraw_scorumpower_object::next_vesting_withdrawal >, member< withdraw_scorumpower_object, withdraw_scorumpower_id_type, &withdraw_scorumpower_object::id > > > > > withdraw_scorumpower_index
Definition: asset.cpp:15
std::vector< std::reference_wrapper< const withdraw_scorumpower_object > > withdraw_scorumpower_refs_type