BitShares-Core  7.0.2
BitShares blockchain node software and command-line wallet software
account_history_plugin.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Cryptonomex, Inc., and 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 
26 #include <graphene/app/plugin.hpp>
27 
28 #include <boost/multi_index/composite_key.hpp>
29 
30 namespace graphene { namespace account_history {
31  using namespace chain;
32 
33 //
34 // Plugins should #define their SPACE_ID's so plugins with
35 // conflicting SPACE_ID assignments can be compiled into the
36 // same binary (by simply re-assigning some of the conflicting #defined
37 // SPACE_ID's in a build script).
38 //
39 // Assignment of SPACE_ID's cannot be done at run-time because
40 // various template automagic depends on them being known at compile
41 // time.
42 //
43 #ifndef ACCOUNT_HISTORY_SPACE_ID
44 #define ACCOUNT_HISTORY_SPACE_ID 4
45 #endif
46 
48 {
50 };
51 
53 struct exceeded_account_object : public abstract_object<exceeded_account_object,
54  ACCOUNT_HISTORY_SPACE_ID, exceeded_account_object_type>
55 {
57  account_id_type account_id;
59  uint32_t block_num;
60 };
61 
62 struct by_account;
63 struct by_block_num;
64 using exceeded_account_multi_idx_type = multi_index_container<
66  indexed_by<
67  ordered_unique< tag<by_id>, member< object, object_id_type, &object::id > >,
68  ordered_unique< tag<by_account>,
69  member< exceeded_account_object, account_id_type, &exceeded_account_object::account_id > >,
70  ordered_unique< tag<by_block_num>,
71  composite_key<
73  member< exceeded_account_object, uint32_t, &exceeded_account_object::block_num >,
74  member< object, object_id_type, &object::id >
75  >
76  >
77  >
78 >;
79 
81 
82 namespace detail
83 {
84  class account_history_plugin_impl;
85 }
86 
88 {
89  public:
91  ~account_history_plugin() override;
92 
93  std::string plugin_name()const override;
94  void plugin_set_program_options(
95  boost::program_options::options_description& cli,
96  boost::program_options::options_description& cfg) override;
97  void plugin_initialize(const boost::program_options::variables_map& options) override;
98  void plugin_startup() override;
99 
100  flat_set<account_id_type> tracked_accounts()const;
101 
102  private:
103  std::unique_ptr<detail::account_history_plugin_impl> my;
104 };
105 
106 } } //graphene::account_history
107 
109  (account_id)(block_num) )
graphene::account_history::exceeded_account_object_type
@ exceeded_account_object_type
Definition: account_history_plugin.hpp:49
plugin.hpp
graphene::db::abstract_object
Definition: object.hpp:107
graphene::account_history::account_history_object_type
account_history_object_type
Definition: account_history_plugin.hpp:47
graphene::app::application
Definition: application.hpp:91
graphene::account_history::exceeded_account_multi_idx_type
multi_index_container< exceeded_account_object, indexed_by< ordered_unique< tag< by_id >, member< object, object_id_type, &object::id > >, ordered_unique< tag< by_account >, member< exceeded_account_object, account_id_type, &exceeded_account_object::account_id > >, ordered_unique< tag< by_block_num >, composite_key< exceeded_account_object, member< exceeded_account_object, uint32_t, &exceeded_account_object::block_num >, member< object, object_id_type, &object::id > > > > > exceeded_account_multi_idx_type
Definition: account_history_plugin.hpp:78
graphene::app::plugin
Definition: plugin.hpp:100
FC_REFLECT_DERIVED
#define FC_REFLECT_DERIVED(TYPE, INHERITS, MEMBERS)
Specializes fc::reflector for TYPE where type inherits other reflected classes.
Definition: reflect.hpp:305
graphene::account_history::exceeded_account_object::block_num
uint32_t block_num
The height of the block containing the oldest (not yet removed) operation related to this account.
Definition: account_history_plugin.hpp:59
graphene::db::generic_index
Definition: generic_index.hpp:43
graphene::account_history::account_history_plugin
Definition: account_history_plugin.hpp:87
graphene::account_history::exceeded_account_object::account_id
account_id_type account_id
The ID of the account.
Definition: account_history_plugin.hpp:57
graphene
Definition: api.cpp:48
graphene::account_history::exceeded_account_object
This struct tracks accounts that have exceeded the max-ops-per-account limit.
Definition: account_history_plugin.hpp:53
graphene::db::object
base for all database objects
Definition: object.hpp:61