CatapultServer  v0.5.0.1 (Elephant)
NodeInteractionsContainer.h
Go to the documentation of this file.
1 
21 #pragma once
23 #include "catapult/functions.h"
24 #include <list>
25 
26 namespace catapult { namespace ionet {
27 
30  public:
33  {}
34 
36  explicit NodeInteractions(uint32_t numSuccesses, uint32_t numFailures)
37  : NumSuccesses(numSuccesses)
38  , NumFailures(numFailures)
39  {}
40 
41  public:
43  uint32_t NumSuccesses;
44 
46  uint32_t NumFailures;
47  };
48 
51  private:
53  public:
55  explicit NodeInteractionsBucket(Timestamp timestamp)
56  : CreationTime(timestamp)
57  , NumSuccesses(0)
58  , NumFailures(0)
59  {}
60 
61  public:
64 
66  uint32_t NumSuccesses;
67 
69  uint32_t NumFailures;
70  };
71 
72  public:
75 
78 
79  public:
81  NodeInteractions interactions(Timestamp timestamp) const;
82 
83  public:
85  void incrementSuccesses(Timestamp timestamp);
86 
88  void incrementFailures(Timestamp timestamp);
89 
91  void pruneBuckets(Timestamp timestamp);
92 
93  private:
95 
96  private:
97  std::list<NodeInteractionsBucket> m_buckets;
98  };
99 }}
catapult::ionet::NodeInteractionsContainer::m_buckets
std::list< NodeInteractionsBucket > m_buckets
Definition: NodeInteractionsContainer.h:97
catapult::utils::TimeSpan::FromDifference
static constexpr TimeSpan FromDifference(Timestamp end, Timestamp start)
Creates a time span from the difference between start and end.
Definition: TimeSpan.h:64
catapult::ionet::NodeInteractionsContainer::NodeInteractionsBucket::CreationTime
Timestamp CreationTime
Time at which the bucket was created.
Definition: NodeInteractionsContainer.h:63
catapult::ionet::NodeInteractions::NodeInteractions
NodeInteractions(uint32_t numSuccesses, uint32_t numFailures)
Constructs node interactions around numSuccesses and numFailures.
Definition: NodeInteractionsContainer.h:36
catapult::ionet::NodeInteractionsContainer
Node interactions container.
Definition: NodeInteractionsContainer.h:50
catapult::ionet::NodeInteractionsContainer::NodeInteractionsBucket
Definition: NodeInteractionsContainer.h:52
functions.h
catapult::utils::TimeSpan
Represents a time duration.
Definition: TimeSpan.h:30
catapult::ionet::NodeInteractionsContainer::InteractionDuration
static utils::TimeSpan InteractionDuration()
Maximum duration of an interaction.
Definition: NodeInteractionsContainer.cpp:40
catapult::ionet::NodeInteractionsContainer::addInteraction
void addInteraction(Timestamp timestamp, const consumer< NodeInteractionsBucket & > &consumer)
Definition: NodeInteractionsContainer.cpp:71
catapult::ionet::NodeInteractionsContainer::BucketDuration
static utils::TimeSpan BucketDuration()
Maximum duration of an interaction bucket.
Definition: NodeInteractionsContainer.cpp:36
catapult::utils::BaseValue< uint64_t, Timestamp_tag >
NodeInteractionsContainer.h
catapult::utils::TimeSpan::FromHours
static constexpr TimeSpan FromHours(uint64_t hours)
Creates a time span from the given number of hours.
Definition: TimeSpan.h:44
Functional.h
catapult::ionet::NodeInteractionsContainer::NodeInteractionsBucket::NumFailures
uint32_t NumFailures
Number of failed interactions.
Definition: NodeInteractionsContainer.h:69
catapult::ionet::NodeInteractionsContainer::pruneBuckets
void pruneBuckets(Timestamp timestamp)
Prunes buckets at timestamp.
Definition: NodeInteractionsContainer.cpp:64
catapult::ionet::NodeInteractionsContainer::incrementSuccesses
void incrementSuccesses(Timestamp timestamp)
Increments successful interactions at timestamp.
Definition: NodeInteractionsContainer.cpp:56
catapult::ionet::NodeInteractions::NumSuccesses
uint32_t NumSuccesses
Number of successful interactions.
Definition: NodeInteractionsContainer.h:43
catapult::ionet::NodeInteractions
Node interactions.
Definition: NodeInteractionsContainer.h:29
TimeSpan.h
catapult::ionet::NodeInteractions::NumFailures
uint32_t NumFailures
Number of failed interactions.
Definition: NodeInteractionsContainer.h:46
catapult::Timestamp
utils::BaseValue< uint64_t, Timestamp_tag > Timestamp
Definition: src/catapult/types.h:73
NetworkTime.h
catapult
Definition: AddressExtractionExtension.cpp:28
catapult::ionet::NodeInteractionsContainer::NodeInteractionsBucket::NodeInteractionsBucket
NodeInteractionsBucket(Timestamp timestamp)
Constructs a bucket around timestamp.
Definition: NodeInteractionsContainer.h:55
catapult::ionet::NodeInteractionsContainer::incrementFailures
void incrementFailures(Timestamp timestamp)
Increments failed interactions at timestamp.
Definition: NodeInteractionsContainer.cpp:60
catapult::ionet::NodeInteractionsContainer::NodeInteractionsBucket::NumSuccesses
uint32_t NumSuccesses
Number of successful interactions.
Definition: NodeInteractionsContainer.h:66
catapult::ionet::NodeInteractions::NodeInteractions
NodeInteractions()
Default constructor for node interactions.
Definition: NodeInteractionsContainer.h:32
catapult::consumer
std::function< void(TArgs...)> consumer
A consumer function.
Definition: functions.h:35
catapult::ionet::NodeInteractionsContainer::interactions
NodeInteractions interactions(Timestamp timestamp) const
Gets the node interactions at timestamp..
Definition: NodeInteractionsContainer.cpp:44