6 #include <fc/static_variant.hpp>
24 var = variant(std::make_pair(name, v));
57 flat_set<account_name_type>&
owner;
62 flat_set<account_name_type>& own,
63 flat_set<account_name_type>& post,
64 std::vector<authority>& oth)
74 v.get_required_active_authorities(
active);
75 v.get_required_owner_authorities(
owner);
76 v.get_required_posting_authorities(
posting);
77 v.get_required_authorities(other);
87 #define DEFINE_OPERATION_TYPE(OperationType) \
88 DEFINE_OPERATION_SERIALIZATOR(OperationType) \
91 namespace protocol { \
93 void operation_validate(const OperationType& op) \
95 op.visit(scorum::protocol::operation_validate_visitor()); \
98 void operation_get_required_authorities(const OperationType& op, \
99 flat_set<account_name_type>& active, \
100 flat_set<account_name_type>& owner, \
101 flat_set<account_name_type>& posting, \
102 std::vector<authority>& other) \
104 op.visit(scorum::protocol::operation_get_required_auth_visitor(active, owner, posting, other)); \
109 #define DEFINE_OPERATION_SERIALIZATOR(OperationType) \
112 void to_variant(const OperationType& var, fc::variant& vo) \
114 var.visit(from_operation(vo)); \
117 void from_variant(const fc::variant& var, OperationType& vo) \
119 static std::map<std::string, uint32_t> to_tag = []() { \
120 std::map<std::string, uint32_t> name_map; \
121 for (int i = 0; i < OperationType::count(); ++i) \
126 tmp.visit(get_operation_name(n)); \
132 auto ar = var.get_array(); \
135 if (ar[0].is_uint64()) \
136 vo.set_which(ar[0].as_uint64()); \
139 auto itr = to_tag.find(ar[0].as_string()); \
140 FC_ASSERT(itr != to_tag.end(), "Invalid operation name: ${n}", ("n", ar[0])); \
141 vo.set_which(to_tag[ar[0].as_string()]); \
143 vo.visit(fc::to_static_variant(ar[1])); \
std::string name_from_type(const std::string &type_name)
from_operation(variant &dv)
void operator()(const T &v) const
get_operation_name(std::string &dv)
void operator()(const T &v) const
std::vector< authority > & other
void operator()(const T &v) const
flat_set< account_name_type > & owner
flat_set< account_name_type > & active
flat_set< account_name_type > & posting
operation_get_required_auth_visitor(flat_set< account_name_type > &a, flat_set< account_name_type > &own, flat_set< account_name_type > &post, std::vector< authority > &oth)
void operator()(const T &v) const