CatapultServer  v0.5.0.1 (Elephant)
RollbackInfo.h
Go to the documentation of this file.
1 
21 #pragma once
22 #include "RollbackStats.h"
25 #include "catapult/types.h"
26 #include <vector>
27 
28 namespace catapult { namespace sync {
29 
31  enum class RollbackResult {
33  Committed,
34 
36  Ignored
37  };
38 
40  class RollbackInfo {
41  public:
43  explicit RollbackInfo(const chain::TimeSupplier& timeSupplier, const utils::TimeSpan& recentStatsTimeSpan);
44 
45  public:
47  size_t counter(RollbackResult rollbackResult, RollbackCounterType rollbackCounterType) const;
48 
49  public:
51  void increment();
52 
54  void reset();
55 
57  void save();
58 
59  private:
60  void prune();
61 
62  private:
66 
69  };
70 }}
catapult::utils::SubtractNonNegative
constexpr Timestamp SubtractNonNegative(const Timestamp &timestamp, const TimeSpan &timeSpan)
Subtracts timeSpan from timestamp and returns the maximum of the difference and zero.
Definition: TimeSpan.h:139
catapult::sync::RollbackCounterType
RollbackCounterType
Rollback counter types.
Definition: RollbackStats.h:28
catapult::sync::RollbackStats::prune
void prune(Timestamp threshold)
Prunes statistics below time threshold.
Definition: RollbackStats.cpp:54
catapult::sync::RollbackInfo::m_currentRollbackSize
size_t m_currentRollbackSize
Definition: RollbackInfo.h:65
RollbackStats.h
catapult::utils::TimeSpan
Represents a time duration.
Definition: TimeSpan.h:30
catapult::sync::RollbackInfo::save
void save()
Adds counter to committed statistics and resets the counter.
Definition: RollbackInfo.cpp:49
Elements.h
catapult::sync::RollbackInfo::reset
void reset()
Adds counter to ignored statistics and resets the counter.
Definition: RollbackInfo.cpp:42
catapult::sync::RollbackInfo::m_recentStatsTimeSpan
const utils::TimeSpan m_recentStatsTimeSpan
Definition: RollbackInfo.h:64
catapult::sync::RollbackInfo::increment
void increment()
Increments counter.
Definition: RollbackInfo.cpp:38
RollbackInfo.h
m_timeSupplier
TimeSupplier m_timeSupplier
Definition: JointValidator.cpp:85
catapult::sync::RollbackInfo::m_ignored
RollbackStats m_ignored
Definition: RollbackInfo.h:68
catapult::sync::RollbackResult
RollbackResult
Rollback results.
Definition: RollbackInfo.h:31
catapult::sync::RollbackResult::Committed
Committed rollback counters.
catapult::sync::RollbackInfo
Container for both committed and ignored rollback statistics.
Definition: RollbackInfo.h:40
catapult::sync::RollbackStats::total
uint64_t total(RollbackCounterType rollbackCounterType) const
Returns statistics for a type (rollbackCounterType).
Definition: RollbackStats.cpp:30
TimeSpan.h
catapult::sync::RollbackInfo::RollbackInfo
RollbackInfo(const chain::TimeSupplier &timeSupplier, const utils::TimeSpan &recentStatsTimeSpan)
Creates a container around timeSupplier with recent stats span (recentStatsTimeSpan).
Definition: RollbackInfo.cpp:26
ChainFunctions.h
catapult::chain::TimeSupplier
supplier< Timestamp > TimeSupplier
Supplies a timestamp.
Definition: ChainFunctions.h:39
types.h
catapult::sync::RollbackResult::Ignored
Ignored rollback counters.
catapult
Definition: AddressExtractionExtension.cpp:28
catapult::sync::RollbackInfo::counter
size_t counter(RollbackResult rollbackResult, RollbackCounterType rollbackCounterType) const
Returns rollback counter for result (rollbackResult) and counter type (rollbackCounterType).
Definition: RollbackInfo.cpp:32
catapult::sync::RollbackStats
Container for rollback statistics.
Definition: RollbackStats.h:40
catapult::sync::RollbackInfo::m_committed
RollbackStats m_committed
Definition: RollbackInfo.h:67
catapult::sync::RollbackInfo::m_timeSupplier
chain::TimeSupplier m_timeSupplier
Definition: RollbackInfo.h:63
catapult::sync::RollbackStats::add
void add(Timestamp timestamp, size_t rollbackSize)
Adds info about rollbackSize at timestamp to current statistics.
Definition: RollbackStats.cpp:45
catapult::sync::RollbackInfo::prune
void prune()
Definition: RollbackInfo.cpp:56