CatapultServer  v0.5.0.1 (Elephant)
SubscriptionManager.h
Go to the documentation of this file.
1 
21 #pragma once
22 #include "NodeSubscriber.h"
23 #include "StateChangeSubscriber.h"
31 #include "catapult/utils/Casting.h"
32 
33 namespace catapult { namespace config { class CatapultConfiguration; } }
34 
35 namespace catapult { namespace subscribers {
36 
39  public:
41  explicit SubscriptionManager(const config::CatapultConfiguration& config);
42 
43  public:
46 
47  public:
49  void addBlockChangeSubscriber(std::unique_ptr<io::BlockChangeSubscriber>&& pSubscriber);
50 
52  void addUtChangeSubscriber(std::unique_ptr<cache::UtChangeSubscriber>&& pSubscriber);
53 
55  void addPtChangeSubscriber(std::unique_ptr<cache::PtChangeSubscriber>&& pSubscriber);
56 
58  void addTransactionStatusSubscriber(std::unique_ptr<TransactionStatusSubscriber>&& pSubscriber);
59 
61  void addStateChangeSubscriber(std::unique_ptr<StateChangeSubscriber>&& pSubscriber);
62 
64  void addNodeSubscriber(std::unique_ptr<NodeSubscriber>&& pSubscriber);
65 
66  public:
68  std::unique_ptr<io::BlockChangeSubscriber> createBlockChangeSubscriber();
69 
71  std::unique_ptr<cache::UtChangeSubscriber> createUtChangeSubscriber();
72 
74  std::unique_ptr<cache::PtChangeSubscriber> createPtChangeSubscriber();
75 
77  std::unique_ptr<TransactionStatusSubscriber> createTransactionStatusSubscriber();
78 
80  std::unique_ptr<StateChangeSubscriber> createStateChangeSubscriber();
81 
83  std::unique_ptr<NodeSubscriber> createNodeSubscriber();
84 
85  public:
88  std::unique_ptr<io::BlockStorage> createBlockStorage(io::BlockChangeSubscriber*& pSubscriber);
89 
92  std::unique_ptr<cache::MemoryUtCacheProxy> createUtCache(const cache::MemoryCacheOptions& options);
93 
96  std::unique_ptr<cache::MemoryPtCacheProxy> createPtCache(const cache::MemoryCacheOptions& options);
97 
98  private:
100 
101  private:
102  void requireUnused(SubscriberType subscriberType) const;
103 
104  void markUsed(SubscriberType subscriberType);
105 
106  private:
108  std::unique_ptr<io::FileBlockStorage> m_pStorage;
110 
111  std::vector<std::unique_ptr<io::BlockChangeSubscriber>> m_blockChangeSubscribers;
112  std::vector<std::unique_ptr<cache::UtChangeSubscriber>> m_utChangeSubscribers;
113  std::vector<std::unique_ptr<cache::PtChangeSubscriber>> m_ptChangeSubscribers;
114  std::vector<std::unique_ptr<TransactionStatusSubscriber>> m_transactionStatusSubscribers;
115  std::vector<std::unique_ptr<StateChangeSubscriber>> m_stateChangeSubscribers;
116  std::vector<std::unique_ptr<NodeSubscriber>> m_nodeSubscribers;
117  };
118 }}
catapult::subscribers::SubscriptionManager::SubscriberType::PtChange
catapult::cache::CreateAggregatePtCache
std::unique_ptr< PtCache > CreateAggregatePtCache(PtCache &ptCache, std::unique_ptr< PtChangeSubscriber > &&pPtChangeSubscriber)
Creates an aggregate pt cache that delegates to ptCache and publishes pt transaction changes to pPtCh...
Definition: AggregatePtCache.cpp:90
AggregateBlockChangeSubscriber.h
AggregateNodeSubscriber.h
catapult::subscribers::SubscriptionManager::createBlockStorage
std::unique_ptr< io::BlockStorage > createBlockStorage(io::BlockChangeSubscriber *&pSubscriber)
Definition: SubscriptionManager.cpp:129
catapult::subscribers::SubscriptionManager::m_config
const config::CatapultConfiguration & m_config
Definition: SubscriptionManager.h:107
catapult::subscribers::SubscriptionManager::m_nodeSubscribers
std::vector< std::unique_ptr< NodeSubscriber > > m_nodeSubscribers
Definition: SubscriptionManager.h:116
AggregateUtCache.h
catapult::validators::ValidationResult
ValidationResult
Enumeration of all possible validation results.
Definition: ValidationResult.h:51
catapult::subscribers::SubscriptionManager::createUtChangeSubscriber
std::unique_ptr< cache::UtChangeSubscriber > createUtChangeSubscriber()
Creates the ut change subscriber.
Definition: SubscriptionManager.cpp:86
BlockChangeSubscriber.h
AggregateUtChangeSubscriber.h
AggregatePtChangeSubscriber.h
catapult::utils::to_underlying_type
constexpr std::underlying_type_t< TEnum > to_underlying_type(TEnum value)
Converts a strongly typed enumeration value to its underlying integral value.
Definition: Casting.h:37
catapult::subscribers::SubscriptionManager::m_utChangeSubscribers
std::vector< std::unique_ptr< cache::UtChangeSubscriber > > m_utChangeSubscribers
Definition: SubscriptionManager.h:112
catapult::subscribers::SubscriptionManager::SubscriberType::StateChange
AggregateBlockStorage.h
MemoryPtCache.h
catapult::io::BlockChangeSubscriber
Block change subscriber.
Definition: BlockChangeSubscriber.h:27
catapult::subscribers::SubscriptionManager::markUsed
void markUsed(SubscriberType subscriberType)
Definition: SubscriptionManager.cpp:169
AggregatePtCache.h
catapult::subscribers::SubscriptionManager::m_ptChangeSubscribers
std::vector< std::unique_ptr< cache::PtChangeSubscriber > > m_ptChangeSubscribers
Definition: SubscriptionManager.h:113
catapult::subscribers::SubscriptionManager::addPtChangeSubscriber
void addPtChangeSubscriber(std::unique_ptr< cache::PtChangeSubscriber > &&pSubscriber)
Registers a partial transactions change subscriber (pSubscriber).
Definition: SubscriptionManager.cpp:57
catapult::subscribers::SubscriptionManager::createStateChangeSubscriber
std::unique_ptr< StateChangeSubscriber > createStateChangeSubscriber()
Creates the state change subscriber.
Definition: SubscriptionManager.cpp:115
catapult::subscribers::SubscriptionManager::SubscriberType::TransactionStatus
catapult::subscribers::SubscriptionManager::SubscriberType::Node
catapult::subscribers::SubscriptionManager::createBlockChangeSubscriber
std::unique_ptr< io::BlockChangeSubscriber > createBlockChangeSubscriber()
Creates the block change subscriber.
Definition: SubscriptionManager.cpp:81
FileBlockStorage.h
catapult::subscribers::SubscriptionManager::createNodeSubscriber
std::unique_ptr< NodeSubscriber > createNodeSubscriber()
Creates the node subscriber.
Definition: SubscriptionManager.cpp:120
catapult::subscribers::SubscriptionManager::m_blockChangeSubscribers
std::vector< std::unique_ptr< io::BlockChangeSubscriber > > m_blockChangeSubscribers
Definition: SubscriptionManager.h:111
SubscriptionManager.h
TransactionStatusSubscriber.h
MemoryUtCache.h
AggregateTransactionStatusSubscriber.h
catapult::config::CatapultConfiguration
Comprehensive configuration for a catapult process.
Definition: CatapultConfiguration.h:34
catapult::subscribers::SubscriptionManager::addNodeSubscriber
void addNodeSubscriber(std::unique_ptr< NodeSubscriber > &&pSubscriber)
Adds a node subscriber (pSubscriber).
Definition: SubscriptionManager.cpp:72
catapult::io::CreateAggregateBlockStorage
std::unique_ptr< BlockStorage > CreateAggregateBlockStorage(std::unique_ptr< BlockStorage > &&pStorage, std::unique_ptr< BlockChangeSubscriber > &&pBlockChangeSubscriber)
Creates an aggregate block storage that delegates to pStorage and publishes block changes to pBlockCh...
Definition: AggregateBlockStorage.cpp:80
catapult::subscribers::SubscriptionManager::addBlockChangeSubscriber
void addBlockChangeSubscriber(std::unique_ptr< io::BlockChangeSubscriber > &&pSubscriber)
Registers a block change subscriber (pSubscriber).
Definition: SubscriptionManager.cpp:47
catapult::subscribers::SubscriptionManager::addStateChangeSubscriber
void addStateChangeSubscriber(std::unique_ptr< StateChangeSubscriber > &&pSubscriber)
Adds a state change subscriber (pSubscriber).
Definition: SubscriptionManager.cpp:67
m_config
HarvestingConfiguration m_config
Definition: HarvestingService.cpp:126
PtChangeSubscriber.h
catapult::subscribers::SubscriptionManager::fileStorage
io::BlockStorage & fileStorage()
Gets the underlying file storage.
Definition: SubscriptionManager.cpp:41
UtChangeSubscriber.h
catapult::cache::CreateAggregateUtCache
std::unique_ptr< UtCache > CreateAggregateUtCache(UtCache &utCache, std::unique_ptr< UtChangeSubscriber > &&pUtChangeSubscriber)
Creates an aggregate ut cache that delegates to utCache and publishes ut transaction changes to pUtCh...
Definition: AggregateUtCache.cpp:72
CATAPULT_LOG_LEVEL
#define CATAPULT_LOG_LEVEL(LEVEL)
Writes a log entry to the default logger with LEVEL severity.
Definition: Logging.h:336
NodeSubscriber.h
catapult::subscribers::SubscriptionManager::createPtChangeSubscriber
std::unique_ptr< cache::PtChangeSubscriber > createPtChangeSubscriber()
Creates the pt change subscriber.
Definition: SubscriptionManager.cpp:91
CatapultConfiguration.h
catapult::subscribers::SubscriptionManager::addUtChangeSubscriber
void addUtChangeSubscriber(std::unique_ptr< cache::UtChangeSubscriber > &&pSubscriber)
Registers an unconfirmed transactions change subscriber (pSubscriber).
Definition: SubscriptionManager.cpp:52
catapult::subscribers::SubscriptionManager::requireUnused
void requireUnused(SubscriberType subscriberType) const
Definition: SubscriptionManager.cpp:159
catapult::subscribers::SubscriptionManager::SubscriberType::BlockChange
catapult::subscribers::SubscriptionManager::m_transactionStatusSubscribers
std::vector< std::unique_ptr< TransactionStatusSubscriber > > m_transactionStatusSubscribers
Definition: SubscriptionManager.h:114
catapult::subscribers::SubscriptionManager::SubscriptionManager
SubscriptionManager(const config::CatapultConfiguration &config)
Creates a new subscription manager around config.
Definition: SubscriptionManager.cpp:35
catapult::model::Transaction::Deadline
Timestamp Deadline
Transaction deadline.
Definition: Transaction.h:38
catapult::subscribers::SubscriptionManager::createTransactionStatusSubscriber
std::unique_ptr< TransactionStatusSubscriber > createTransactionStatusSubscriber()
Creates the transaction status subscriber.
Definition: SubscriptionManager.cpp:96
catapult::subscribers::SubscriptionManager::createPtCache
std::unique_ptr< cache::MemoryPtCacheProxy > createPtCache(const cache::MemoryCacheOptions &options)
Definition: SubscriptionManager.cpp:149
Casting.h
CATAPULT_THROW_INVALID_ARGUMENT
#define CATAPULT_THROW_INVALID_ARGUMENT(MESSAGE)
Macro used to throw a catapult invalid argument.
Definition: exceptions.h:179
catapult::subscribers::SubscriptionManager::SubscriberType::Count
catapult::subscribers::SubscriptionManager::SubscriberType::UtChange
catapult
Definition: AddressExtractionExtension.cpp:28
catapult::io::BlockStorage
Interface for saving and loading blocks.
Definition: BlockStorage.h:50
m_pStorage
std::unique_ptr< BlockStorage > m_pStorage
Definition: AggregateBlockStorage.cpp:75
AggregateStateChangeSubscriber.h
catapult::validators::MapToLogLevel
constexpr utils::LogLevel MapToLogLevel(ValidationResult result)
Maps validation result to an appropriate logging level.
Definition: ValidationResult.h:100
catapult::subscribers::SubscriptionManager::SubscriberType
SubscriberType
Definition: SubscriptionManager.h:99
catapult::utils::ByteArray< Hash256_Size, Hash256_tag >
catapult::cache::MemoryCacheOptions
Options for customizing the behavior of a memory based cache.
Definition: MemoryCacheOptions.h:27
catapult::subscribers::SubscriptionManager::createUtCache
std::unique_ptr< cache::MemoryUtCacheProxy > createUtCache(const cache::MemoryCacheOptions &options)
Definition: SubscriptionManager.cpp:141
catapult::subscribers::SubscriptionManager::addTransactionStatusSubscriber
void addTransactionStatusSubscriber(std::unique_ptr< TransactionStatusSubscriber > &&pSubscriber)
Adds a transaction status subscriber (pSubscriber).
Definition: SubscriptionManager.cpp:62
catapult::subscribers::SubscriptionManager::m_pStorage
std::unique_ptr< io::FileBlockStorage > m_pStorage
Definition: SubscriptionManager.h:108
StateChangeSubscriber.h
catapult::subscribers::TransactionStatusSubscriber
Transaction status subscriber.
Definition: TransactionStatusSubscriber.h:30
catapult::subscribers::SubscriptionManager::m_stateChangeSubscribers
std::vector< std::unique_ptr< StateChangeSubscriber > > m_stateChangeSubscribers
Definition: SubscriptionManager.h:115
catapult::subscribers::SubscriptionManager
A manager for subscribing to notifications.
Definition: SubscriptionManager.h:38
catapult::model::Transaction
Binary layout for a transaction.
Definition: Transaction.h:32
catapult::subscribers::SubscriptionManager::m_subscriberUsedFlags
std::array< bool, utils::to_underlying_type(SubscriberType::Count)> m_subscriberUsedFlags
Definition: SubscriptionManager.h:109