BitShares-Core  7.0.2
BitShares blockchain node software and command-line wallet 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 
fc::rate_limiting_group::set_actual_rate_time_constant
void set_actual_rate_time_constant(microseconds time_constant)
Definition: rate_limiting.cpp:506
fc::rate_limiting_group::remove_tcp_socket
void remove_tcp_socket(tcp_socket *tcp_socket_to_stop_limiting)
Definition: rate_limiting.cpp:537
fc::rate_limiting_group::get_actual_download_rate
uint32_t get_actual_download_rate() const
Definition: rate_limiting.cpp:501
fc
Definition: api.hpp:15
fc::rate_limiting_group::get_actual_upload_rate
uint32_t get_actual_upload_rate() const
Definition: rate_limiting.cpp:496
fc::rate_limiting_group::set_upload_limit
void set_upload_limit(uint32_t upload_bytes_per_second)
Definition: rate_limiting.cpp:512
fc::tcp_socket
Definition: tcp_socket.hpp:14
fc::rate_limiting_group::add_tcp_socket
void add_tcp_socket(tcp_socket *tcp_socket_to_limit)
Definition: rate_limiting.cpp:532
fc::microseconds
Definition: time.hpp:12
fc::rate_limiting_group_ptr
std::shared_ptr< rate_limiting_group > rate_limiting_group_ptr
Definition: rate_limiting.hpp:38
fc::rate_limiting_group::set_download_limit
void set_download_limit(uint32_t download_bytes_per_second)
Definition: rate_limiting.cpp:522
time.hpp
fc::rate_limiting_group::get_download_limit
uint32_t get_download_limit() const
Definition: rate_limiting.cpp:527
fc::rate_limiting_group::rate_limiting_group
rate_limiting_group(uint32_t upload_bytes_per_second, uint32_t download_bytes_per_second, uint32_t burstiness_in_seconds=1)
Definition: rate_limiting.cpp:487
fc::rate_limiting_group::~rate_limiting_group
~rate_limiting_group()
Definition: rate_limiting.cpp:492
fc::rate_limiting_group::get_upload_limit
uint32_t get_upload_limit() const
Definition: rate_limiting.cpp:517
fc::rate_limiting_group
Definition: rate_limiting.hpp:17