Scorum
comment.cpp
Go to the documentation of this file.
3 
4 namespace scorum {
5 namespace protocol {
6 
8 {
9  uint32_t sum = 0;
10 
11  FC_ASSERT(beneficiaries.size(), "Must specify at least one beneficiary");
12  FC_ASSERT(beneficiaries.size() < 128,
13  "Cannot specify more than 127 beneficiaries."); // Require size serialization fits in one byte.
14 
16  FC_ASSERT(beneficiaries[0].weight <= SCORUM_100_PERCENT,
17  "Cannot allocate more than 100% of rewards to one account");
18  sum += beneficiaries[0].weight;
19  FC_ASSERT(
20  sum <= SCORUM_100_PERCENT,
21  "Cannot allocate more than 100% of rewards to a comment"); // Have to check incrementally to avoid overflow
22 
23  for (size_t i = 1; i < beneficiaries.size(); i++)
24  {
26  FC_ASSERT(beneficiaries[i].weight <= SCORUM_100_PERCENT,
27  "Cannot allocate more than 100% of rewards to one account");
28  sum += beneficiaries[i].weight;
29  FC_ASSERT(
30  sum <= SCORUM_100_PERCENT,
31  "Cannot allocate more than 100% of rewards to a comment"); // Have to check incrementally to avoid overflow
32  FC_ASSERT(beneficiaries[i - 1] < beneficiaries[i],
33  "Benficiaries must be specified in sorted order (account ascending)");
34  }
35 }
36 }
37 }
#define SCORUM_100_PERCENT
Definition: config.hpp:200
void validate_account_name(const std::string &name)
Definition: base.hpp:15
Definition: asset.cpp:15
std::vector< beneficiary_route_type > beneficiaries
Definition: comment.hpp:31