Scorum
shared_authority.hpp
Go to the documentation of this file.
1 #pragma once
3 #include <fc/shared_containers.hpp>
4 
5 namespace scorum {
6 namespace chain {
11 
18 {
19 private:
20  shared_authority() = delete;
21 
22 public:
23  template <typename Allocator>
24  shared_authority(const authority& a, const Allocator& alloc)
25  : account_auths(alloc)
26  , key_auths(alloc)
27  {
28  account_auths.reserve(a.account_auths.size());
29  key_auths.reserve(a.key_auths.size());
30  for (const auto& item : a.account_auths)
31  account_auths.insert(item);
32  for (const auto& item : a.key_auths)
33  key_auths.insert(item);
35  }
36 
40  , key_auths(cpy.key_auths)
41  {
42  }
43 
44  template <typename Allocator>
45  shared_authority(const Allocator& alloc)
46  : account_auths(alloc)
47  , key_auths(alloc)
48  {
49  }
50 
51  template <typename Allocator, class... Args>
52  shared_authority(const Allocator& alloc, uint32_t weight_threshold, Args... auths)
54  , account_auths(alloc)
55  , key_auths(alloc)
56  {
57  add_authorities(auths...);
58  }
59 
60  operator authority() const;
61 
63 
66 
67  template <typename AuthType> void add_authorities(AuthType k, authority_weight_type w)
68  {
69  add_authority(k, w);
70  }
71 
72  template <typename AuthType, class... Args> void add_authorities(AuthType k, authority_weight_type w, Args... auths)
73  {
74  add_authority(k, w);
75  add_authorities(auths...);
76  }
77 
78  std::vector<public_key_type> get_keys() const;
79 
80  bool is_impossible() const;
81  uint32_t num_auths() const;
82  void clear();
83  void validate() const;
84 
85  typedef fc::shared_flat_map<account_name_type, authority_weight_type> account_authority_map;
86  typedef fc::shared_flat_map<public_key_type, authority_weight_type> key_authority_map;
87 
88  uint32_t weight_threshold = 0;
91 };
92 
93 bool operator==(const shared_authority& a, const shared_authority& b);
94 bool operator==(const authority& a, const shared_authority& b);
95 bool operator==(const shared_authority& a, const authority& b);
96 }
97 } // scorum::chain
98 
100 FC_REFLECT(scorum::chain::shared_authority, (weight_threshold)(account_auths)(key_auths))
FC_REFLECT(appender_args,(appender)(stream)) FC_REFLECT_DERIVED(file_appender_args
bool operator==(const shared_authority &a, const shared_authority &b)
fc::fixed_string_16 account_name_type
Definition: types.hpp:62
uint16_t authority_weight_type
Definition: types.hpp:68
Definition: asset.cpp:15
shared_authority(const authority &a, const Allocator &alloc)
shared_authority & operator=(const authority &a)
void add_authorities(AuthType k, authority_weight_type w, Args... auths)
void add_authority(const public_key_type &k, authority_weight_type w)
std::vector< public_key_type > get_keys() const
account_authority_map account_auths
shared_authority(const Allocator &alloc)
shared_authority(const shared_authority &cpy)
fc::shared_flat_map< public_key_type, authority_weight_type > key_authority_map
fc::shared_flat_map< account_name_type, authority_weight_type > account_authority_map
void add_authorities(AuthType k, authority_weight_type w)
shared_authority(const Allocator &alloc, uint32_t weight_threshold, Args... auths)
account_authority_map account_auths
Definition: authority.hpp:55
key_authority_map key_auths
Definition: authority.hpp:56