|
| 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 | +#include <graphene/protocol/authority.hpp> |
| 26 | +#include <graphene/protocol/custom_authority.hpp> |
| 27 | +#include <graphene/protocol/restriction_predicate.hpp> |
| 28 | +#include <graphene/db/generic_index.hpp> |
| 29 | +#include <graphene/chain/types.hpp> |
| 30 | +#include <boost/multi_index/composite_key.hpp> |
| 31 | + |
| 32 | +namespace graphene { namespace chain { |
| 33 | + |
| 34 | + /** |
| 35 | + * @brief Tracks account custom authorities |
| 36 | + * @ingroup object |
| 37 | + * |
| 38 | + */ |
| 39 | + class custom_authority_object : public abstract_object<custom_authority_object> { |
| 40 | + public: |
| 41 | + static const uint8_t space_id = protocol_ids; |
| 42 | + static const uint8_t type_id = custom_authority_object_type; |
| 43 | + |
| 44 | + account_id_type account; |
| 45 | + bool enabled; |
| 46 | + time_point_sec valid_from; |
| 47 | + time_point_sec valid_to; |
| 48 | + unsigned_int operation_type; |
| 49 | + authority auth; |
| 50 | + vector<restriction> restrictions; |
| 51 | + |
| 52 | + /// Unreflected field to store a cache of the predicate function |
| 53 | + optional<restriction_predicate_function> predicate_cache; |
| 54 | + }; |
| 55 | + |
| 56 | + struct by_account_custom; |
| 57 | + |
| 58 | + /** |
| 59 | + * @ingroup object_index |
| 60 | + */ |
| 61 | + typedef multi_index_container< |
| 62 | + custom_authority_object, |
| 63 | + indexed_by< |
| 64 | + ordered_unique<tag<by_id>, member<object, object_id_type, &object::id>>, |
| 65 | + ordered_unique<tag<by_account_custom>, |
| 66 | + composite_key< |
| 67 | + custom_authority_object, |
| 68 | + member<custom_authority_object, account_id_type, &custom_authority_object::account>, |
| 69 | + member<object, object_id_type, &object::id> |
| 70 | + > |
| 71 | + > |
| 72 | + > |
| 73 | + > custom_authority_multi_index_type; |
| 74 | + |
| 75 | + /** |
| 76 | + * @ingroup object_index |
| 77 | + */ |
| 78 | + using custom_authority_index = generic_index<custom_authority_object, custom_authority_multi_index_type>; |
| 79 | + |
| 80 | +} } // graphene::chain |
| 81 | + |
| 82 | +MAP_OBJECT_ID_TO_TYPE(graphene::chain::custom_authority_object) |
| 83 | + |
| 84 | +FC_REFLECT_TYPENAME(graphene::chain::custom_authority_object) |
| 85 | + |
| 86 | +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION(graphene::chain::custom_authority_object) |
0 commit comments