Scorum
withdraw_scorumpower_route.cpp
Go to the documentation of this file.
6 
7 namespace scorum {
8 namespace chain {
9 
11 {
12 public:
14  : dbs_base(db)
15  {
16  }
17 
18  template <typename FromIdType>
20  {
22 
23  const auto& idx = db_impl().get_index<withdraw_scorumpower_route_index>().indices().get<by_withdraw_route>();
24 
25  withdrawable_id_type from_id = from;
26  auto it = idx.upper_bound(boost::make_tuple(from_id, withdrawable_id_type()));
27  const auto it_end = idx.cend();
28  while (is_equal_withdrawable_id(it->from_id, from_id) && it != it_end)
29  {
30  ret.push_back(std::cref(*it));
31  ++it;
32  }
33 
34  return ret;
35  }
36 
37  template <typename FromIdType> uint16_t total_percent(const FromIdType& from) const
38  {
39  uint16_t total_percent = 0;
40  for (const withdraw_scorumpower_route_object& wvro : get_all(from))
41  {
42  total_percent += wvro.percent;
43  }
44  return total_percent;
45  }
46 };
47 
49  : base_service_type(db)
51 {
52 }
53 
55 {
56 }
57 
59 {
60  return find_by<by_withdraw_route>(boost::make_tuple(withdrawable_id_type(from), withdrawable_id_type(to)))
61  != nullptr;
62 }
63 
65 {
66  return find_by<by_withdraw_route>(boost::make_tuple(withdrawable_id_type(from), withdrawable_id_type(to)))
67  != nullptr;
68 }
69 
71 {
72  return find_by<by_withdraw_route>(boost::make_tuple(withdrawable_id_type(from), withdrawable_id_type(to)))
73  != nullptr;
74 }
75 
77 {
78  return find_by<by_withdraw_route>(boost::make_tuple(withdrawable_id_type(from), withdrawable_id_type(to)))
79  != nullptr;
80 }
81 
83  const account_id_type& to) const
84 {
85  try
86  {
87  return get_by<by_withdraw_route>(boost::make_tuple(withdrawable_id_type(from), withdrawable_id_type(to)));
88  }
89  FC_CAPTURE_AND_RETHROW((from)(to))
90 }
91 
93  const dev_committee_id_type& to) const
94 {
95  try
96  {
97  return get_by<by_withdraw_route>(boost::make_tuple(withdrawable_id_type(from), withdrawable_id_type(to)));
98  }
99  FC_CAPTURE_AND_RETHROW((from)(to))
100 }
101 
103  const dev_committee_id_type& to) const
104 {
105  try
106  {
107  return get_by<by_withdraw_route>(boost::make_tuple(withdrawable_id_type(from), withdrawable_id_type(to)));
108  }
109  FC_CAPTURE_AND_RETHROW((from)(to))
110 }
111 
113  const account_id_type& to) const
114 {
115  try
116  {
117  return get_by<by_withdraw_route>(boost::make_tuple(withdrawable_id_type(from), withdrawable_id_type(to)));
118  }
119  FC_CAPTURE_AND_RETHROW((from)(to))
120 }
121 
124 {
125  return _impl->get_all(from);
126 }
127 
129 {
130  return _impl->total_percent(from);
131 }
132 
134 {
135  return _impl->total_percent(from);
136 }
137 
138 } // namespace chain
139 } // namespace scorum
tracks the blockchain state in an extensible manner
Definition: database.hpp:52
dba::db_index & db_impl()
Definition: dbs_base.cpp:22
dbs_withdraw_scorumpower_route::withdraw_scorumpower_route_refs_type get_all(const FromIdType &from) const
virtual uint16_t total_percent(const account_id_type &from) const override
virtual withdraw_scorumpower_route_refs_type get_all(const withdrawable_id_type &from) const override
bool is_equal_withdrawable_id(const withdrawable_id_type &a, const withdrawable_id_type &b)
fc::static_variant< account_id_type, dev_committee_id_type > withdrawable_id_type
shared_multi_index_container< withdraw_scorumpower_route_object, indexed_by< ordered_unique< tag< by_id >, member< withdraw_scorumpower_route_object, withdraw_scorumpower_route_id_type, &withdraw_scorumpower_route_object::id > >, ordered_unique< tag< by_withdraw_route >, composite_key< withdraw_scorumpower_route_object, member< withdraw_scorumpower_route_object, withdrawable_id_type, &withdraw_scorumpower_route_object::from_id >, member< withdraw_scorumpower_route_object, withdrawable_id_type, &withdraw_scorumpower_route_object::to_id > >, composite_key_compare< less_for_withdrawable_id, less_for_withdrawable_id > >, ordered_unique< tag< by_destination >, composite_key< withdraw_scorumpower_route_object, member< withdraw_scorumpower_route_object, withdrawable_id_type, &withdraw_scorumpower_route_object::to_id >, member< withdraw_scorumpower_route_object, withdraw_scorumpower_route_id_type, &withdraw_scorumpower_route_object::id > >, composite_key_compare< less_for_withdrawable_id, std::less< withdraw_scorumpower_route_id_type > > > > > withdraw_scorumpower_route_index
Definition: asset.cpp:15
std::vector< std::reference_wrapper< const withdraw_scorumpower_route_object > > withdraw_scorumpower_route_refs_type