BitShares-Core  5.0.0
BitShares blockchain implementation and command-line interface software
rate_limiting.hpp
Go to the documentation of this file.
1 #pragma once
2 #include <stdint.h>
3 
4 #include <memory>
5 
6 #include <fc/time.hpp>
7 
8 namespace fc
9 {
10  namespace detail
11  {
12  class rate_limiting_group_impl;
13  }
14 
15  class tcp_socket;
16 
18  {
19  public:
20  rate_limiting_group(uint32_t upload_bytes_per_second, uint32_t download_bytes_per_second, uint32_t burstiness_in_seconds = 1);
22 
23  void set_upload_limit(uint32_t upload_bytes_per_second);
24  uint32_t get_upload_limit() const;
25 
26  void set_download_limit(uint32_t download_bytes_per_second);
27  uint32_t get_download_limit() const;
28 
29  uint32_t get_actual_upload_rate() const;
30  uint32_t get_actual_download_rate() const;
31  void set_actual_rate_time_constant(microseconds time_constant);
32 
33  void add_tcp_socket(tcp_socket* tcp_socket_to_limit);
34  void remove_tcp_socket(tcp_socket* tcp_socket_to_stop_limiting);
35  private:
36  std::unique_ptr<detail::rate_limiting_group_impl> my;
37  };
38  typedef std::shared_ptr<rate_limiting_group> rate_limiting_group_ptr;
39 
40 } // namesapce fc
41 
std::shared_ptr< rate_limiting_group > rate_limiting_group_ptr
Definition: api.hpp:15