Scorum
account_statistics_api.cpp
Go to the documentation of this file.
4 
5 namespace scorum {
6 namespace account_statistics {
7 
8 namespace detail {
10 {
11 public:
14  {
15  }
16 };
17 } // namespace detail
18 
20 {
21  my = std::make_shared<detail::account_statistics_api_impl>(ctx.app);
22 }
23 
25 {
26 }
27 
28 statistics account_statistics_api::get_stats_for_time(const fc::time_point_sec& open, uint32_t interval) const
29 {
30  return my->_app.chain_database()->with_read_lock([&]() { return my->get_stats_for_time(open, interval); });
31 }
32 
34  const fc::time_point_sec& end) const
35 {
36  return my->_app.chain_database()->with_read_lock(
37  [&]() { return my->get_stats_for_interval<account_statistics_plugin>(start, end); });
38 }
39 
41 {
42  return my->_app.chain_database()->with_read_lock([&]() { return my->get_lifetime_stats(); });
43 }
44 
46  const fc::time_point_sec& open,
47  uint32_t interval) const
48 {
49  return my->_app.chain_database()->with_read_lock([&]() {
50  statistics account_stat;
51  account_stat.statistic_map[account_name] = my->get_stats_for_time(open, interval).statistic_map[account_name];
52  return account_stat;
53  });
54 }
55 
57  const fc::time_point_sec& start,
58  const fc::time_point_sec& end) const
59 {
60  return my->_app.chain_database()->with_read_lock([&]() {
61  statistics account_stat;
62  account_stat.statistic_map[account_name]
63  = my->get_stats_for_interval<account_statistics_plugin>(start, end).statistic_map[account_name];
64  return account_stat;
65  });
66 }
67 
69 {
70  return my->_app.chain_database()->with_read_lock([&]() {
71  statistics account_stat;
72  account_stat.statistic_map[account_name] = my->get_lifetime_stats().statistic_map[account_name];
73  return account_stat;
74  });
75 }
76 
77 } // namespace account_statistics
78 } // namespace scorum
#define ACCOUNT_STATISTICS_PLUGIN_NAME
account_statistics_api(const scorum::app::api_context &ctx)
statistics get_stats_for_interval_by_account_name(const account_name_type &account_name, const fc::time_point_sec &start, const fc::time_point_sec &end) const
statistics get_lifetime_stats_by_account_name(const account_name_type &account_name) const
statistics get_stats_for_time_by_account_name(const account_name_type &account_name, const fc::time_point_sec &open, uint32_t interval) const
statistics get_stats_for_time(const fc::time_point_sec &open, uint32_t interval) const
Gets statistics over the time window length, interval, that contains time, open.
statistics get_lifetime_stats() const
Returns lifetime statistics.
statistics get_stats_for_interval(const fc::time_point_sec &start, const fc::time_point_sec &stop) const
Aggregates statistics over a time interval.
fc::fixed_string_16 account_name_type
Definition: types.hpp:62
Definition: asset.cpp:15
std::map< account_name_type, account_statistic > statistic_map
Definition: metrics.hpp:77