BitShares-Core  7.0.2
BitShares blockchain node software and command-line wallet 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  bool is_virtual;
87  account_id_type fee_payer;
88  std::string op;
89  std::string operation_result;
92 };
93 
94 struct block_struct {
95  uint32_t block_num;
97  std::string trx_id;
98 };
99 
100 struct fee_struct {
101  asset_id_type asset;
102  std::string asset_name;
104  double amount_units;
105 };
106 
108  asset_id_type asset;
109  std::string asset_name;
111  double amount_units;
112  account_id_type from;
113  account_id_type to;
114 };
115 
116 struct fill_struct {
117  object_id_type order_id;
118  account_id_type account_id;
119  asset_id_type pays_asset_id;
120  std::string pays_asset_name;
123  asset_id_type receives_asset_id;
124  std::string receives_asset_name;
127  double fill_price;
129  bool is_maker;
130 };
131 
136 };
137 
138 struct bulk_struct {
141  int64_t operation_type;
144  optional<visitor_struct> additional_data;
145 };
146 
147 } } //graphene::elasticsearch
148 
149 FC_REFLECT_ENUM( graphene::elasticsearch::mode, (only_save)(only_query)(all) )
151  (trx_in_block)(op_in_trx)(virtual_op)(is_virtual)(fee_payer)
152  (op)(operation_result)(op_object)(operation_result_object) )
153 FC_REFLECT( graphene::elasticsearch::block_struct, (block_num)(block_time)(trx_id) )
154 FC_REFLECT( graphene::elasticsearch::fee_struct, (asset)(asset_name)(amount)(amount_units) )
155 FC_REFLECT( graphene::elasticsearch::transfer_struct, (asset)(asset_name)(amount)(amount_units)(from)(to) )
157  (order_id)(account_id)(pays_asset_id)(pays_asset_name)(pays_amount)(pays_amount_units)
158  (receives_asset_id)(receives_asset_name)(receives_amount)(receives_amount_units)(fill_price)
159  (fill_price_units)(is_maker) )
160 FC_REFLECT( graphene::elasticsearch::visitor_struct, (fee_data)(transfer_data)(fill_data) )
162  (account_history)(operation_history)(operation_type)(operation_id_num)(block_data)(additional_data) )
graphene::elasticsearch::operation_history_struct::op_in_trx
uint16_t op_in_trx
Definition: elasticsearch_plugin.hpp:84
graphene::elasticsearch::fee_struct::asset_name
std::string asset_name
Definition: elasticsearch_plugin.hpp:102
graphene::elasticsearch::fee_struct::amount
share_type amount
Definition: elasticsearch_plugin.hpp:103
graphene::elasticsearch::fill_struct::receives_amount_units
double receives_amount_units
Definition: elasticsearch_plugin.hpp:126
graphene::elasticsearch::fill_struct::receives_asset_id
asset_id_type receives_asset_id
Definition: elasticsearch_plugin.hpp:123
graphene::elasticsearch::transfer_struct
Definition: elasticsearch_plugin.hpp:107
database.hpp
graphene::elasticsearch::fill_struct::receives_amount
share_type receives_amount
Definition: elasticsearch_plugin.hpp:125
graphene::elasticsearch::transfer_struct::asset_name
std::string asset_name
Definition: elasticsearch_plugin.hpp:109
graphene::elasticsearch::operation_history_struct::fee_payer
account_id_type fee_payer
Definition: elasticsearch_plugin.hpp:87
graphene::elasticsearch::fill_struct::pays_amount_units
double pays_amount_units
Definition: elasticsearch_plugin.hpp:122
elasticsearch.hpp
graphene::elasticsearch::bulk_struct::account_history
account_history_object account_history
Definition: elasticsearch_plugin.hpp:139
graphene::elasticsearch::fill_struct::order_id
object_id_type order_id
Definition: elasticsearch_plugin.hpp:117
graphene::elasticsearch::transfer_struct::asset
asset_id_type asset
Definition: elasticsearch_plugin.hpp:108
graphene::elasticsearch::bulk_struct::operation_type
int64_t operation_type
Definition: elasticsearch_plugin.hpp:141
graphene::elasticsearch::operation_history_struct::operation_result_object
variant operation_result_object
Definition: elasticsearch_plugin.hpp:91
graphene::elasticsearch::fill_struct::pays_asset_name
std::string pays_asset_name
Definition: elasticsearch_plugin.hpp:120
graphene::elasticsearch::transfer_struct::to
account_id_type to
Definition: elasticsearch_plugin.hpp:113
plugin.hpp
graphene::elasticsearch::visitor_struct::transfer_data
transfer_struct transfer_data
Definition: elasticsearch_plugin.hpp:134
graphene::elasticsearch::visitor_struct::fill_data
fill_struct fill_data
Definition: elasticsearch_plugin.hpp:135
graphene::elasticsearch::bulk_struct::operation_history
operation_history_struct operation_history
Definition: elasticsearch_plugin.hpp:140
graphene::elasticsearch::fee_struct::amount_units
double amount_units
Definition: elasticsearch_plugin.hpp:104
graphene::elasticsearch::bulk_struct
Definition: elasticsearch_plugin.hpp:138
graphene::elasticsearch::visitor_struct::fee_data
fee_struct fee_data
Definition: elasticsearch_plugin.hpp:133
graphene::app::application
Definition: application.hpp:91
graphene::elasticsearch::bulk_struct::additional_data
optional< visitor_struct > additional_data
Definition: elasticsearch_plugin.hpp:144
graphene::elasticsearch::fill_struct::account_id
account_id_type account_id
Definition: elasticsearch_plugin.hpp:118
graphene::elasticsearch::fill_struct::pays_amount
share_type pays_amount
Definition: elasticsearch_plugin.hpp:121
graphene::elasticsearch::fill_struct::is_maker
bool is_maker
Definition: elasticsearch_plugin.hpp:129
graphene::app::plugin
Definition: plugin.hpp:100
graphene::elasticsearch::operation_history_struct::op
std::string op
Definition: elasticsearch_plugin.hpp:88
graphene::elasticsearch::mode::all
@ all
fc::time_point_sec
Definition: time.hpp:74
graphene::elasticsearch::transfer_struct::amount
share_type amount
Definition: elasticsearch_plugin.hpp:110
graphene::elasticsearch::fill_struct::fill_price_units
double fill_price_units
Definition: elasticsearch_plugin.hpp:128
graphene::elasticsearch::operation_history_struct::operation_result
std::string operation_result
Definition: elasticsearch_plugin.hpp:89
graphene::elasticsearch::visitor_struct
Definition: elasticsearch_plugin.hpp:132
graphene::elasticsearch::operation_history_struct
Definition: elasticsearch_plugin.hpp:82
graphene::elasticsearch::fill_struct::fill_price
double fill_price
Definition: elasticsearch_plugin.hpp:127
graphene::elasticsearch::mode::only_query
@ only_query
graphene::protocol::share_type
safe< int64_t > share_type
Definition: types.hpp:309
graphene::elasticsearch::transfer_struct::from
account_id_type from
Definition: elasticsearch_plugin.hpp:112
graphene::elasticsearch::operation_history_struct::op_object
variant op_object
Definition: elasticsearch_plugin.hpp:90
graphene::elasticsearch::fee_struct
Definition: elasticsearch_plugin.hpp:100
graphene::elasticsearch::bulk_struct::block_data
block_struct block_data
Definition: elasticsearch_plugin.hpp:143
graphene::elasticsearch::mode
mode
Definition: elasticsearch_plugin.hpp:53
graphene::elasticsearch::elasticsearch_plugin
Definition: elasticsearch_plugin.hpp:55
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
graphene::elasticsearch::mode::only_save
@ only_save
graphene::elasticsearch::fill_struct::receives_asset_name
std::string receives_asset_name
Definition: elasticsearch_plugin.hpp:124
fc::variant
stores null, int64, uint64, double, bool, string, std::vector<variant>, and variant_object's.
Definition: variant.hpp:198
graphene::chain::account_history_object
a node in a linked list of operation_history_objects
Definition: operation_history_object.hpp:95
graphene::elasticsearch::fill_struct
Definition: elasticsearch_plugin.hpp:116
operation_history_object.hpp
graphene::elasticsearch::operation_history_struct::trx_in_block
uint16_t trx_in_block
Definition: elasticsearch_plugin.hpp:83
graphene::protocol::operation_result
fc::static_variant< void_result, object_id_type, asset, generic_operation_result, generic_exchange_operation_result, extendable_operation_result > operation_result
Definition: base.hpp:122
graphene::elasticsearch::fill_struct::pays_asset_id
asset_id_type pays_asset_id
Definition: elasticsearch_plugin.hpp:119
graphene::elasticsearch::bulk_struct::operation_id_num
uint64_t operation_id_num
Definition: elasticsearch_plugin.hpp:142
graphene::elasticsearch::block_struct::block_num
uint32_t block_num
Definition: elasticsearch_plugin.hpp:95
graphene::elasticsearch::fee_struct::asset
asset_id_type asset
Definition: elasticsearch_plugin.hpp:101
graphene::elasticsearch::transfer_struct::amount_units
double amount_units
Definition: elasticsearch_plugin.hpp:111
FC_REFLECT
#define FC_REFLECT(TYPE, MEMBERS)
Specializes fc::reflector for TYPE.
Definition: reflect.hpp:388
graphene::elasticsearch::block_struct::trx_id
std::string trx_id
Definition: elasticsearch_plugin.hpp:97
graphene::elasticsearch::operation_history_struct::is_virtual
bool is_virtual
Definition: elasticsearch_plugin.hpp:86
graphene::elasticsearch::operation_history_struct::virtual_op
uint32_t virtual_op
Definition: elasticsearch_plugin.hpp:85
graphene::elasticsearch::block_struct
Definition: elasticsearch_plugin.hpp:94
graphene
Definition: api.cpp:48
graphene::elasticsearch::block_struct::block_time
fc::time_point_sec block_time
Definition: elasticsearch_plugin.hpp:96
graphene::chain::operation_history_object
tracks the history of all logical operations on blockchain state
Definition: operation_history_object.hpp:48
fc::safe
Definition: safe.hpp:26