CatapultServer  v0.5.0.1 (Elephant)
AccountCounters.h
Go to the documentation of this file.
1 
21 #pragma once
22 #include "catapult/utils/Hashers.h"
23 #include "catapult/types.h"
24 #include <unordered_map>
25 
26 namespace catapult { namespace cache {
27 
30  public:
33 
34  public:
36  size_t size() const;
37 
39  size_t deepSize() const;
40 
42  size_t count(const Key& key) const;
43 
44  public:
46  void increment(const Key& key);
47 
49  void decrement(const Key& key);
50 
52  void reset();
53 
54  private:
55  std::unordered_map<Key, size_t, utils::ArrayHasher<Key>> m_accountCounters;
57  };
58 }}
catapult::cache::AccountCounters::decrement
void decrement(const Key &key)
Decreases the use count for the account with public key.
Definition: AccountCounters.cpp:48
catapult::cache::AccountCounters::size
size_t size() const
Gets the number of unique accounts used.
Definition: AccountCounters.cpp:30
catapult::cache::AccountCounters::m_totalUseCount
size_t m_totalUseCount
Definition: AccountCounters.h:56
exceptions.h
catapult::cache::AccountCounters::reset
void reset()
Resets the counters.
Definition: AccountCounters.cpp:60
CATAPULT_THROW_RUNTIME_ERROR_1
#define CATAPULT_THROW_RUNTIME_ERROR_1(MESSAGE, PARAM1)
Macro used to throw a catapult runtime error with a single parameter.
Definition: exceptions.h:171
HexFormatter.h
catapult::cache::AccountCounters::increment
void increment(const Key &key)
Increases the use count for the account with public key.
Definition: AccountCounters.cpp:43
catapult::cache::AccountCounters::AccountCounters
AccountCounters()
Creates account counters.
Definition: AccountCounters.cpp:27
catapult::cache::AccountCounters::deepSize
size_t deepSize() const
Gets the sum of all use counts.
Definition: AccountCounters.cpp:34
AccountCounters.h
catapult::cache::AccountCounters::m_accountCounters
std::unordered_map< Key, size_t, utils::ArrayHasher< Key > > m_accountCounters
Definition: AccountCounters.h:55
catapult::cache::AccountCounters::count
size_t count(const Key &key) const
Gets the use count for the account with public key.
Definition: AccountCounters.cpp:38
types.h
catapult
Definition: AddressExtractionExtension.cpp:28
Hashers.h
catapult::utils::ByteArray< Key_Size, Key_tag >
catapult::cache::AccountCounters
Counters for tracking how often an account is used.
Definition: AccountCounters.h:29