Expose get_relative_account_history to cli_wallet (#277)
This commit is contained in:
parent
fb825774c0
commit
d482273add
2 changed files with 51 additions and 0 deletions
|
|
@ -354,6 +354,15 @@ class wallet_api
|
||||||
*/
|
*/
|
||||||
vector<operation_detail> get_account_history(string name, int limit)const;
|
vector<operation_detail> get_account_history(string name, int limit)const;
|
||||||
|
|
||||||
|
/** Returns the relative operations on the named account from start number.
|
||||||
|
*
|
||||||
|
* @param name the name or id of the account
|
||||||
|
* @param stop Sequence number of earliest operation.
|
||||||
|
* @param limit the number of entries to return
|
||||||
|
* @param start the sequence number where to start looping back throw the history
|
||||||
|
* @returns a list of \c operation_history_objects
|
||||||
|
*/
|
||||||
|
vector<operation_detail> get_relative_account_history(string name, uint32_t stop, int limit, uint32_t start)const;
|
||||||
|
|
||||||
vector<bucket_object> get_market_history(string symbol, string symbol2, uint32_t bucket, fc::time_point_sec start, fc::time_point_sec end)const;
|
vector<bucket_object> get_market_history(string symbol, string symbol2, uint32_t bucket, fc::time_point_sec start, fc::time_point_sec end)const;
|
||||||
vector<limit_order_object> get_limit_orders(string a, string b, uint32_t limit)const;
|
vector<limit_order_object> get_limit_orders(string a, string b, uint32_t limit)const;
|
||||||
|
|
@ -1651,6 +1660,7 @@ FC_API( graphene::wallet::wallet_api,
|
||||||
(get_block)
|
(get_block)
|
||||||
(get_account_count)
|
(get_account_count)
|
||||||
(get_account_history)
|
(get_account_history)
|
||||||
|
(get_relative_account_history)
|
||||||
(is_public_key_registered)
|
(is_public_key_registered)
|
||||||
(get_market_history)
|
(get_market_history)
|
||||||
(get_global_properties)
|
(get_global_properties)
|
||||||
|
|
|
||||||
|
|
@ -2088,6 +2088,23 @@ public:
|
||||||
|
|
||||||
return ss.str();
|
return ss.str();
|
||||||
};
|
};
|
||||||
|
m["get_relative_account_history"] = [this](variant result, const fc::variants& a)
|
||||||
|
{
|
||||||
|
auto r = result.as<vector<operation_detail>>();
|
||||||
|
std::stringstream ss;
|
||||||
|
|
||||||
|
for( operation_detail& d : r )
|
||||||
|
{
|
||||||
|
operation_history_object& i = d.op;
|
||||||
|
auto b = _remote_db->get_block_header(i.block_num);
|
||||||
|
FC_ASSERT(b);
|
||||||
|
ss << b->timestamp.to_iso_string() << " ";
|
||||||
|
i.op.visit(operation_printer(ss, *this, i.result));
|
||||||
|
ss << " \n";
|
||||||
|
}
|
||||||
|
|
||||||
|
return ss.str();
|
||||||
|
};
|
||||||
|
|
||||||
m["list_account_balances"] = [this](variant result, const fc::variants& a)
|
m["list_account_balances"] = [this](variant result, const fc::variants& a)
|
||||||
{
|
{
|
||||||
|
|
@ -2818,6 +2835,30 @@ vector<operation_detail> wallet_api::get_account_history(string name, int limit)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vector<operation_detail> wallet_api::get_relative_account_history(string name, uint32_t stop, int limit, uint32_t start)const
|
||||||
|
{
|
||||||
|
|
||||||
|
FC_ASSERT( start > 0 || limit <= 100 );
|
||||||
|
|
||||||
|
vector<operation_detail> result;
|
||||||
|
auto account_id = get_account(name).get_id();
|
||||||
|
|
||||||
|
while( limit > 0 )
|
||||||
|
{
|
||||||
|
vector <operation_history_object> current = my->_remote_hist->get_relative_account_history(account_id, stop, std::min<uint32_t>(100, limit), start);
|
||||||
|
for (auto &o : current) {
|
||||||
|
std::stringstream ss;
|
||||||
|
auto memo = o.op.visit(detail::operation_printer(ss, *my, o.result));
|
||||||
|
result.push_back(operation_detail{memo, ss.str(), o});
|
||||||
|
}
|
||||||
|
if (current.size() < std::min<uint32_t>(100, limit))
|
||||||
|
break;
|
||||||
|
limit -= current.size();
|
||||||
|
start -= 100;
|
||||||
|
if( start == 0 ) break;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
vector<bucket_object> wallet_api::get_market_history( string symbol1, string symbol2, uint32_t bucket , fc::time_point_sec start, fc::time_point_sec end )const
|
vector<bucket_object> wallet_api::get_market_history( string symbol1, string symbol2, uint32_t bucket , fc::time_point_sec start, fc::time_point_sec end )const
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue