CatapultServer  v0.5.0.1 (Elephant)
ApiStateChangeSubscriber.h
Go to the documentation of this file.
1 
21 #pragma once
22 #include "ChainScoreProvider.h"
23 #include "ExternalCacheStorage.h"
26 
27 namespace catapult { namespace mongo {
28 
31  public:
34  std::unique_ptr<ChainScoreProvider>&& pChainScoreProvider,
35  std::unique_ptr<ExternalCacheStorage>&& pCacheStorage)
36  : m_pChainScoreProvider(std::move(pChainScoreProvider))
37  , m_pCacheStorage(std::move(pCacheStorage))
38  {}
39 
40  public:
41  void notifyScoreChange(const model::ChainScore& chainScore) override {
42  m_pChainScoreProvider->saveScore(chainScore);
43  }
44 
45  void notifyStateChange(const subscribers::StateChangeInfo& stateChangeInfo) override {
46  m_pCacheStorage->saveDelta(stateChangeInfo.CacheChanges);
47  }
48 
49  private:
50  std::unique_ptr<ChainScoreProvider> m_pChainScoreProvider;
51  std::unique_ptr<ExternalCacheStorage> m_pCacheStorage;
52  };
53 }}
catapult::subscribers::StateChangeSubscriber
State change subscriber.
Definition: StateChangeSubscriber.h:31
ChainScoreProvider.h
StateChangeInfo.h
catapult::model::ChainScore
Definition: ChainScore.h:30
ExternalCacheStorage.h
catapult::mongo::ApiStateChangeSubscriber::m_pCacheStorage
std::unique_ptr< ExternalCacheStorage > m_pCacheStorage
Definition: ApiStateChangeSubscriber.h:51
catapult::mongo::ApiStateChangeSubscriber::notifyStateChange
void notifyStateChange(const subscribers::StateChangeInfo &stateChangeInfo) override
Indicates state was changed with change information in stateChangeInfo.
Definition: ApiStateChangeSubscriber.h:45
catapult::mongo::ApiStateChangeSubscriber
Api state change subscriber.
Definition: ApiStateChangeSubscriber.h:30
catapult::mongo::ApiStateChangeSubscriber::notifyScoreChange
void notifyScoreChange(const model::ChainScore &chainScore) override
Indicates chain score was changed to chainScore.
Definition: ApiStateChangeSubscriber.h:41
catapult::subscribers::StateChangeInfo
State change information.
Definition: StateChangeInfo.h:29
catapult
Definition: AddressExtractionExtension.cpp:28
catapult::mongo::ApiStateChangeSubscriber::m_pChainScoreProvider
std::unique_ptr< ChainScoreProvider > m_pChainScoreProvider
Definition: ApiStateChangeSubscriber.h:50
catapult::subscribers::StateChangeInfo::CacheChanges
const cache::CacheChanges CacheChanges
Cache changes.
Definition: StateChangeInfo.h:40
StateChangeSubscriber.h
catapult::mongo::ApiStateChangeSubscriber::ApiStateChangeSubscriber
ApiStateChangeSubscriber(std::unique_ptr< ChainScoreProvider > &&pChainScoreProvider, std::unique_ptr< ExternalCacheStorage > &&pCacheStorage)
Creates a subscriber around pChainScoreProvider and pCacheStorage.
Definition: ApiStateChangeSubscriber.h:33