BitShares-Core  6.1.0
BitShares blockchain implementation and command-line interface software
elasticsearch_plugin.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 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>
30 
31 namespace graphene { namespace elasticsearch {
32  using namespace chain;
33 
34 //
35 // Plugins should #define their SPACE_ID's so plugins with
36 // conflicting SPACE_ID assignments can be compiled into the
37 // same binary (by simply re-assigning some of the conflicting #defined
38 // SPACE_ID's in a build script).
39 //
40 // Assignment of SPACE_ID's cannot be done at run-time because
41 // various template automagic depends on them being known at compile
42 // time.
43 //
44 #ifndef ELASTICSEARCH_SPACE_ID
45 #define ELASTICSEARCH_SPACE_ID 6
46 #endif
47 
48 namespace detail
49 {
50  class elasticsearch_plugin_impl;
51 }
52 
53 enum class mode { only_save = 0 , only_query = 1, all = 2 };
54 
56 {
57  public:
59  ~elasticsearch_plugin() override;
60 
61  std::string plugin_name()const override;
62  std::string plugin_description()const override;
63  void plugin_set_program_options(
64  boost::program_options::options_description& cli,
65  boost::program_options::options_description& cfg) override;
66  void plugin_initialize(const boost::program_options::variables_map& options) override;
67  void plugin_startup() override;
68 
69  operation_history_object get_operation_by_id(const operation_history_id_type& id) const;
70  vector<operation_history_object> get_account_history(
71  const account_id_type& account_id,
72  const operation_history_id_type& stop = operation_history_id_type(),
73  uint64_t limit = 100,
74  const operation_history_id_type& start = operation_history_id_type() ) const;
75  mode get_running_mode() const;
76 
77  private:
78  std::unique_ptr<detail::elasticsearch_plugin_impl> my;
79 };
80 
81 
83  uint16_t trx_in_block;
84  uint16_t op_in_trx;
85  uint32_t virtual_op;
86  account_id_type fee_payer;
87  std::string op;
88  std::string operation_result;
89  variant op_object;
91 };
92 
93 struct block_struct {
94  uint32_t block_num;
96  std::string trx_id;
97 };
98 
99 struct fee_struct {
100  asset_id_type asset;
101  std::string asset_name;
103  double amount_units;
104 };
105 
107  asset_id_type asset;
108  std::string asset_name;
110  double amount_units;
111  account_id_type from;
112  account_id_type to;
113 };
114 
115 struct fill_struct {
116  object_id_type order_id;
117  account_id_type account_id;
118  asset_id_type pays_asset_id;
119  std::string pays_asset_name;
122  asset_id_type receives_asset_id;
123  std::string receives_asset_name;
126  double fill_price;
128  bool is_maker;
129 };
130 
135 };
136 
137 struct bulk_struct {
140  int64_t operation_type;
144 };
145 
146 } } //graphene::elasticsearch
147 
150  (trx_in_block)(op_in_trx)(virtual_op)(fee_payer)
151  (op)(operation_result)(op_object)(operation_result_object) )
152 FC_REFLECT( graphene::elasticsearch::block_struct, (block_num)(block_time)(trx_id) )
153 FC_REFLECT( graphene::elasticsearch::fee_struct, (asset)(asset_name)(amount)(amount_units) )
154 FC_REFLECT( graphene::elasticsearch::transfer_struct, (asset)(asset_name)(amount)(amount_units)(from)(to) )
156  (order_id)(account_id)(pays_asset_id)(pays_asset_name)(pays_amount)(pays_amount_units)
157  (receives_asset_id)(receives_asset_name)(receives_amount)(receives_amount_units)(fill_price)
158  (fill_price_units)(is_maker) )
159 FC_REFLECT( graphene::elasticsearch::visitor_struct, (fee_data)(transfer_data)(fill_data) )
161  (account_history)(operation_history)(operation_type)(operation_id_num)(block_data)(additional_data) )
#define FC_REFLECT(TYPE, MEMBERS)
Specializes fc::reflector for TYPE.
Definition: reflect.hpp:388
tracks the history of all logical operations on blockchain stateAll operations and virtual operations...
Definition: api.cpp:48
optional< visitor_struct > additional_data
provides stack-based nullable value similar to boost::optional
Definition: optional.hpp:20
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
a node in a linked list of operation_history_objectsAccount history is important for users and wallet...
safe< int64_t > share_type
Definition: types.hpp:309