xrpld
Toggle main menu visibility
Loading...
Searching...
No Matches
include
xrpl
peerfinder
detail
Fixed.h
1
#pragma once
2
3
#include <xrpl/peerfinder/Types.h>
4
#include <xrpl/peerfinder/detail/Tuning.h>
5
6
#include <
algorithm
>
7
#include <
chrono
>
8
#include <
cstddef
>
9
10
namespace
xrpl::peer_finder
{
11
15
class
Fixed
16
{
17
public
:
18
explicit
Fixed
(
ClockType
& clock) :
when_
(clock.now())
19
{
20
}
21
22
Fixed
(
Fixed
const
&) =
default
;
23
27
[[nodiscard]]
ClockType::time_point
const
&
28
when
()
const
29
{
30
return
when_
;
31
}
32
36
void
37
failure
(
ClockType::time_point
const
& now)
38
{
39
failures_
=
std::min
(
failures_
+ 1,
tuning::kConnectionBackoff
.size() - 1);
40
when_
= now +
std::chrono::minutes
(
tuning::kConnectionBackoff
[
failures_
]);
41
}
42
46
void
47
success
(
ClockType::time_point
const
& now)
48
{
49
failures_
= 0;
50
when_
= now;
51
}
52
53
private
:
54
ClockType::time_point
when_
;
55
std::size_t
failures_
{0};
56
};
57
58
}
// namespace xrpl::peer_finder
algorithm
chrono
beast::AbstractClock< std::chrono::steady_clock >::time_point
std::chrono::steady_clock::time_point time_point
Definition
abstract_clock.h:41
xrpl::peer_finder::Fixed::failures_
std::size_t failures_
Definition
Fixed.h:55
xrpl::peer_finder::Fixed::success
void success(ClockType::time_point const &now)
Updates metadata to reflect a successful connection.
Definition
Fixed.h:47
xrpl::peer_finder::Fixed::Fixed
Fixed(Fixed const &)=default
xrpl::peer_finder::Fixed::failure
void failure(ClockType::time_point const &now)
Updates metadata to reflect a failed connection.
Definition
Fixed.h:37
xrpl::peer_finder::Fixed::when_
ClockType::time_point when_
Definition
Fixed.h:54
xrpl::peer_finder::Fixed::Fixed
Fixed(ClockType &clock)
Definition
Fixed.h:18
xrpl::peer_finder::Fixed::when
ClockType::time_point const & when() const
Returns the time after which we should allow a connection attempt.
Definition
Fixed.h:28
cstddef
std::chrono::minutes
std::min
T min(T... args)
xrpl::peer_finder::tuning::kConnectionBackoff
static std::array< int, 10 > const kConnectionBackoff
Definition
include/xrpl/peerfinder/detail/Tuning.h:63
xrpl::peer_finder
Definition
include/xrpl/peerfinder/Config.h:12
xrpl::peer_finder::ClockType
beast::AbstractClock< std::chrono::steady_clock > ClockType
Definition
peerfinder/Types.h:13
std::size_t
Generated by
1.17.0