BitShares-Core  7.0.2
BitShares blockchain node software and command-line wallet software
restriction_predicate.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019 Contributors.
3  *
4  * The MIT License
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22  * THE SOFTWARE.
23  */
24 #pragma once
25 
28 
29 #include <functional>
30 
31 namespace graphene { namespace protocol {
32 
36  bool success = false;
37 
43  };
44 
49  vector<rejection_indicator> rejection_path;
50 
51  static predicate_result Rejection(rejection_reason reason) { return {false, {reason}}; }
52  static predicate_result Rejection(vector<predicate_result> branches) { return {false, {std::move(branches)}}; }
53  static predicate_result Success() { return {true, {}}; }
54 
55  operator bool() const { return success; }
56 
59 };
60 
63 
71 
72 } } // namespace graphene::protocol
73 
75  (predicate_was_false)(null_optional)(incorrect_variant_type))
77 FC_REFLECT(graphene::protocol::predicate_result, (success)(rejection_path))
fc::static_variant::tag_type
int64_t tag_type
Definition: static_variant.hpp:46
graphene::protocol::get_restriction_predicate
restriction_predicate_function get_restriction_predicate(vector< restriction > rs, operation::tag_type op_type)
get_restriction_predicate Get a predicate function for the supplied restriction
Definition: restriction_predicate.cpp:32
graphene::protocol::predicate_result::incorrect_variant_type
@ incorrect_variant_type
Definition: restriction_predicate.hpp:42
fc::static_variant
Definition: raw_fwd.hpp:27
FC_REFLECT_TYPENAME
FC_REFLECT_TYPENAME(fc::log_message)
graphene::protocol::predicate_result
A type describing the result of a restriction predicate.
Definition: restriction_predicate.hpp:34
graphene::protocol::predicate_result::success
bool success
Whether or not the operation complied with the restrictions or not.
Definition: restriction_predicate.hpp:36
graphene::protocol::predicate_result::Success
static predicate_result Success()
Definition: restriction_predicate.hpp:53
operations.hpp
graphene::protocol::predicate_result::Rejection
static predicate_result Rejection(vector< predicate_result > branches)
Definition: restriction_predicate.hpp:52
graphene::protocol::predicate_result::reverse_path
predicate_result & reverse_path()
Reverse the order of the rejection path. Returns a reference to this object.
Definition: restriction_predicate.cpp:72
restriction.hpp
graphene::protocol::restriction_predicate_function
std::function< predicate_result(const operation &)> restriction_predicate_function
A restriction predicate is a function accepting an operation and returning a predicate_result.
Definition: restriction_predicate.hpp:62
graphene::protocol::predicate_result::Rejection
static predicate_result Rejection(rejection_reason reason)
Definition: restriction_predicate.hpp:51
FC_REFLECT_ENUM
FC_REFLECT_ENUM(graphene::net::core_message_type_enum,(trx_message_type)(block_message_type)(core_message_type_first)(item_ids_inventory_message_type)(blockchain_item_ids_inventory_message_type)(fetch_blockchain_item_ids_message_type)(fetch_items_message_type)(item_not_available_message_type)(hello_message_type)(connection_accepted_message_type)(connection_rejected_message_type)(address_request_message_type)(address_message_type)(closing_connection_message_type)(current_time_request_message_type)(current_time_reply_message_type)(check_firewall_message_type)(check_firewall_reply_message_type)(get_current_connections_request_message_type)(get_current_connections_reply_message_type)(core_message_type_last))(different_chain)(already_connected)(connected_to_self)(not_accepting_connections)(blocked)(invalid_hello_message)(client_too_old))(inbound)(outbound))(firewalled)(not_firewalled))(unable_to_connect)(connection_successful)) namespace std
Definition: core_messages.hpp:404
FC_REFLECT
#define FC_REFLECT(TYPE, MEMBERS)
Specializes fc::reflector for TYPE.
Definition: reflect.hpp:388
graphene::protocol::predicate_result::predicate_was_false
@ predicate_was_false
Definition: restriction_predicate.hpp:40
graphene::protocol::predicate_result::rejection_path
vector< rejection_indicator > rejection_path
Failure indicators, ordered from the outermost restriction to the innermost (the location of the reje...
Definition: restriction_predicate.hpp:49
graphene::protocol::predicate_result::rejection_reason
rejection_reason
Enumeration of the general reasons a predicate may reject.
Definition: restriction_predicate.hpp:39
graphene
Definition: api.cpp:48
graphene::protocol::predicate_result::null_optional
@ null_optional
Definition: restriction_predicate.hpp:41