13 namespace blockchain_history {
27 template <
typename history_
object_type,
typename fill_result_functor>
28 void get_history(
const std::string& account, uint64_t from, uint32_t limit, fill_result_functor& funct)
const
32 FC_ASSERT(limit > 0,
"Limit must be greater than zero");
34 "Limit of ${l} is greater than maxmimum allowed ${2}",
36 FC_ASSERT(from >= limit,
"From must be greater than limit");
39 auto itr = idx.lower_bound(boost::make_tuple(account, from));
42 auto end = idx.upper_bound(boost::make_tuple(account, int64_t(0)));
43 int64_t pos = int64_t(itr->sequence) - limit;
46 end = idx.lower_bound(boost::make_tuple(account, pos));
56 template <
typename history_
object_type>
57 std::map<uint32_t, applied_operation>
get_history(
const std::string& account, uint64_t from, uint32_t limit)
const
59 std::map<uint32_t, applied_operation>
result;
63 auto fill_funct = [&](
const history_object_type& hobj) {
result[hobj.sequence] = db->get(hobj.op); };
64 this->
template get_history<history_object_type>(account, from, limit, fill_funct);
72 : _impl(new detail::account_history_api_impl(ctx.app))
84 std::map<uint32_t, applied_operation>
87 const auto db = _impl->_app.chain_database();
88 return db->with_read_lock(
92 std::map<uint32_t, applied_operation>
95 const auto db = _impl->_app.chain_database();
96 return db->with_read_lock(
100 std::map<uint32_t, applied_operation>
103 const auto db = _impl->_app.chain_database();
104 return db->with_read_lock([&]() {
return _impl->get_history<
account_history_object>(account, from, limit); });
107 std::map<uint32_t, applied_withdraw_operation>
110 const auto db = _impl->_app.chain_database();
111 return db->with_read_lock([&]() {
112 std::map<uint32_t, applied_withdraw_operation>
result;
116 auto& applied_op = it->second;
119 applied_op.op.weak_visit(
122 if (to_withdraw == 0u)
127 else if (!obj.progress.empty())
129 auto last_op = fc::raw::unpack<operation>(db->get(obj.progress.back()).serialized_op);
142 if (obj.progress.size() > 1)
144 auto before_last_op_obj = db->get(*(obj.progress.rbegin() + 1));
145 auto before_last_op = fc::raw::unpack<operation>(before_last_op_obj.serialized_op);
153 for (
auto&
id : obj.progress)
155 auto op = fc::raw::unpack<operation>(db->get(
id).serialized_op);
#define API_ACCOUNT_HISTORY
std::shared_ptr< chain::database > chain_database() const
account_history_api(const scorum::app::api_context &ctx)
scorum::app::application & _app
std::map< uint32_t, applied_operation > get_history(const std::string &account, uint64_t from, uint32_t limit) const
account_history_api_impl(scorum::app::application &app)
void get_history(const std::string &account, uint64_t from, uint32_t limit, fill_result_functor &funct) const
std::map< uint32_t, applied_operation > get_account_history(const std::string &account, uint64_t from, uint32_t limit) const
std::map< uint32_t, applied_operation > get_account_scr_to_scr_transfers(const std::string &account, uint64_t from, uint32_t limit) const
std::map< uint32_t, applied_operation > get_account_scr_to_sp_transfers(const std::string &account, uint64_t from, uint32_t limit) const
std::map< uint32_t, applied_withdraw_operation > get_account_sp_to_scr_transfers(const std::string &account, uint64_t from, uint32_t limit) const
shared_multi_index_container< history_object_t, indexed_by< ordered_unique< tag< by_id >, member< history_object_t, typename history_object_t::id_type, &history_object_t::id > >, ordered_unique< tag< by_account >, composite_key< history_object_t, member< history_object_t, account_name_type, &history_object_t::account >, member< history_object_t, uint32_t, &history_object_t::sequence > >, composite_key_compare< std::less< account_name_type >, std::greater< uint32_t > >> >> account_history_index
fc::safe< share_value_type > share_type
config_api & get_api_config(std::string api_name)