rippled
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 <ripple/peerfinder/impl/Tuning.h>
24 
25 namespace ripple {
26 namespace PeerFinder {
27 
29 class Fixed
30 {
31 public:
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
48  {
49  m_failures =
51  m_when =
53  }
54 
56  void
58  {
59  m_failures = 0;
60  m_when = now;
61  }
62 
63 private:
66 };
67 
68 } // namespace PeerFinder
69 } // namespace ripple
70 
71 #endif
std::chrono::minutes
ripple::PeerFinder::Tuning::connectionBackoff
static const std::array< int, 10 > connectionBackoff
Definition: peerfinder/impl/Tuning.h:79
ripple::PeerFinder::Fixed::Fixed
Fixed(clock_type &clock)
Definition: Fixed.h:32
beast::abstract_clock< std::chrono::steady_clock >
ripple::PeerFinder::Fixed
Metadata for a Fixed slot.
Definition: Fixed.h:29
std::min
T min(T... args)
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::PeerFinder::Fixed::m_failures
std::size_t m_failures
Definition: Fixed.h:65
ripple::PeerFinder::Fixed::when
clock_type::time_point const & when() const
Returns the time after which we shoud allow a connection attempt.
Definition: Fixed.h:40
ripple::PeerFinder::Fixed::m_when
clock_type::time_point m_when
Definition: Fixed.h:64
std::size_t
ripple::PeerFinder::Fixed::failure
void failure(clock_type::time_point const &now)
Updates metadata to reflect a failed connection.
Definition: Fixed.h:47
ripple::PeerFinder::Fixed::success
void success(clock_type::time_point const &now)
Updates metadata to reflect a successful connection.
Definition: Fixed.h:57
beast::abstract_clock< std::chrono::steady_clock >::time_point
typename std::chrono::steady_clock ::time_point time_point
Definition: abstract_clock.h:63