rippled
Loading...
Searching...
No Matches
Fixed.h
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2012, 2013 Ripple Labs Inc.
5
6 Permission to use, copy, modify, and/or distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#ifndef RIPPLE_PEERFINDER_FIXED_H_INCLUDED
21#define RIPPLE_PEERFINDER_FIXED_H_INCLUDED
22
23#include <xrpld/peerfinder/detail/Tuning.h>
24
25namespace ripple {
26namespace PeerFinder {
27
29class Fixed
30{
31public:
32 explicit Fixed(clock_type& clock) : m_when(clock.now()), m_failures(0)
33 {
34 }
35
36 Fixed(Fixed const&) = default;
37
40 when() const
41 {
42 return m_when;
43 }
44
46 void
54
56 void
58 {
59 m_failures = 0;
60 m_when = now;
61 }
62
63private:
66};
67
68} // namespace PeerFinder
69} // namespace ripple
70
71#endif
Metadata for a Fixed slot.
Definition Fixed.h:30
clock_type::time_point const & when() const
Returns the time after which we shoud allow a connection attempt.
Definition Fixed.h:40
clock_type::time_point m_when
Definition Fixed.h:64
Fixed(Fixed const &)=default
void failure(clock_type::time_point const &now)
Updates metadata to reflect a failed connection.
Definition Fixed.h:47
void success(clock_type::time_point const &now)
Updates metadata to reflect a successful connection.
Definition Fixed.h:57
std::size_t m_failures
Definition Fixed.h:65
Fixed(clock_type &clock)
Definition Fixed.h:32
T min(T... args)
static std::array< int, 10 > const connectionBackoff
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:25