Scorum
authority.hpp
Go to the documentation of this file.
1 #pragma once
3 #include <fc/interprocess/container.hpp>
4 
5 namespace scorum {
6 namespace protocol {
7 
8 typedef flat_map<account_name_type, authority_weight_type> account_authority_map;
9 
10 struct authority
11 {
13  {
14  }
15 
16  enum classification
17  {
18  owner = 0,
19  active = 1,
20  key = 2,
21  posting = 3
22  };
23 
24  template <class... Args>
25  authority(uint32_t threshold, Args... auths)
26  : weight_threshold(threshold)
27  {
28  add_authorities(auths...);
29  }
30 
33 
34  template <typename AuthType> void add_authorities(AuthType k, authority_weight_type w)
35  {
36  add_authority(k, w);
37  }
38 
39  template <typename AuthType, class... Args> void add_authorities(AuthType k, authority_weight_type w, Args... auths)
40  {
41  add_authority(k, w);
42  add_authorities(auths...);
43  }
44 
45  std::vector<public_key_type> get_keys() const;
46 
47  bool is_impossible() const;
48  uint32_t num_auths() const;
49  void clear();
50  void validate() const;
51 
52  typedef flat_map<public_key_type, authority_weight_type> key_authority_map;
53 
54  uint32_t weight_threshold = 0;
57 };
58 
59 template <typename AuthorityType>
60 void add_authority_accounts(flat_set<account_name_type>& result, const AuthorityType& a)
61 {
62  for (auto& item : a.account_auths)
63  result.insert(item.first);
64 }
65 
96 bool is_valid_account_name(const std::string& name);
97 
98 bool operator==(const authority& a, const authority& b);
99 }
100 } // namespace scorum::protocol
101 
102 FC_REFLECT_TYPENAME(scorum::protocol::account_authority_map)
104 FC_REFLECT(scorum::protocol::authority, (weight_threshold)(account_auths)(key_auths))
FC_REFLECT(appender_args,(appender)(stream)) FC_REFLECT_DERIVED(file_appender_args
flat_map< account_name_type, authority_weight_type > account_authority_map
Definition: authority.hpp:8
bool operator==(const authority &a, const authority &b)
Definition: authority.cpp:98
fc::fixed_string_16 account_name_type
Definition: types.hpp:62
bool is_valid_account_name(const std::string &name)
Definition: authority.cpp:58
uint16_t authority_weight_type
Definition: types.hpp:68
void add_authority_accounts(flat_set< account_name_type > &result, const AuthorityType &a)
Definition: authority.hpp:60
Definition: asset.cpp:15
authority(uint32_t threshold, Args... auths)
Definition: authority.hpp:25
account_authority_map account_auths
Definition: authority.hpp:55
void add_authorities(AuthType k, authority_weight_type w, Args... auths)
Definition: authority.hpp:39
void add_authorities(AuthType k, authority_weight_type w)
Definition: authority.hpp:34
uint32_t num_auths() const
Definition: authority.cpp:39
key_authority_map key_auths
Definition: authority.hpp:56
flat_map< public_key_type, authority_weight_type > key_authority_map
Definition: authority.hpp:52
void add_authority(const public_key_type &k, authority_weight_type w)
Definition: authority.cpp:10
std::vector< public_key_type > get_keys() const
Definition: authority.cpp:20