35
35
#include < graphene/chain/proposal_object.hpp>
36
36
#include < boost/algorithm/string/join.hpp>
37
37
#include < graphene/chain/balance_object.hpp>
38
+ #include < graphene/chain/market_object.hpp>
38
39
39
40
40
41
namespace graphene { namespace es_objects {
@@ -65,6 +66,7 @@ class es_objects_plugin_impl
65
66
bool _es_objects_accounts = true ;
66
67
bool _es_objects_assets = true ;
67
68
bool _es_objects_balances = true ;
69
+ bool _es_objects_limit_orders = true ;
68
70
bool _es_objects_logs = true ;
69
71
CURL *curl; // curl handler
70
72
vector <string> bulk;
@@ -73,6 +75,7 @@ class es_objects_plugin_impl
73
75
void PrepareAccount (const account_object* account_object);
74
76
void PrepareAsset (const asset_object* asset_object);
75
77
void PrepareBalance (const balance_object* balance_object);
78
+ void PrepareLimit (const limit_order_object* limit_object);
76
79
void SendBulk ();
77
80
void createBulk (std::string type, std::string data, std::string id);
78
81
};
@@ -120,6 +123,12 @@ void es_objects_plugin_impl::updateDatabase( const vector<object_id_type>& ids ,
120
123
if (b != nullptr )
121
124
PrepareBalance (b);
122
125
}
126
+ else if (value.is <limit_order_object>() && _es_objects_limit_orders) {
127
+ auto obj = db.find_object (value);
128
+ auto l = static_cast <const limit_order_object*>(obj);
129
+ if (l != nullptr )
130
+ PrepareLimit (l);
131
+ }
123
132
}
124
133
}
125
134
@@ -259,6 +268,19 @@ void es_objects_plugin_impl::PrepareBalance(const balance_object* balance_object
259
268
createBulk (" balance" , data, fc::json::to_string (balance_object->owner ));
260
269
}
261
270
271
+ void es_objects_plugin_impl::PrepareLimit (const limit_order_object* limit_object)
272
+ {
273
+ limit_order_struct limit;
274
+ limit.expiration = limit_object->expiration ;
275
+ limit.seller = limit_object->seller ;
276
+ limit.for_sale = limit_object->for_sale ;
277
+ limit.sell_price = limit_object->sell_price ;
278
+ limit.deferred_fee = limit_object->deferred_fee ;
279
+
280
+ std::string data = fc::json::to_string (limit);
281
+ createBulk (" limitorder" , data, fc::json::to_string (limit_object->id ));
282
+ }
283
+
262
284
es_objects_plugin_impl::~es_objects_plugin_impl ()
263
285
{
264
286
return ;
@@ -298,7 +320,8 @@ void es_objects_plugin::plugin_set_program_options(
298
320
(" es-objects-proposals" , boost::program_options::value<bool >(), " Store proposal objects" )
299
321
(" es-objects-accounts" , boost::program_options::value<bool >(), " Store account objects" )
300
322
(" es-objects-assets" , boost::program_options::value<bool >(), " Store asset objects" )
301
- (" es-objects-balances" , boost::program_options::value<bool >(), " Store balances object" )
323
+ (" es-objects-balances" , boost::program_options::value<bool >(), " Store balances objects" )
324
+ (" es-objects-limit-orders" , boost::program_options::value<bool >(), " Store limit order objects" )
302
325
303
326
;
304
327
cfg.add (cli);
@@ -333,6 +356,9 @@ void es_objects_plugin::plugin_initialize(const boost::program_options::variable
333
356
if (options.count (" es-objects-balances" )) {
334
357
my->_es_objects_balances = options[" es-objects-balances" ].as <bool >();
335
358
}
359
+ if (options.count (" es-objects-limit-orders" )) {
360
+ my->_es_objects_limit_orders = options[" es-objects-limit-orders" ].as <bool >();
361
+ }
336
362
}
337
363
338
364
void es_objects_plugin::plugin_startup ()
0 commit comments