CatapultServer  v0.5.0.1 (Elephant)
MongoLockInfoCacheStorageTraits.h
Go to the documentation of this file.
1 
21 #pragma once
23 #include "catapult/model/Address.h"
24 
25 namespace catapult { namespace mongo { namespace plugins {
26 
28  template<typename TLockInfoTraits>
29  struct MongoLockInfoCacheStorageTraits : public TLockInfoTraits {
30  public:
31  using CacheDeltaType = typename TLockInfoTraits::CacheDeltaType;
32  using KeyType = typename TLockInfoTraits::KeyType;
33  using ModelType = typename TLockInfoTraits::ModelType;
34 
35  public:
37  static auto MapToMongoId(const KeyType& key) {
38  return mappers::ToBinary(key);
39  }
40 
42  static auto MapToMongoDocument(const ModelType& lockInfo, model::NetworkIdentifier networkIdentifier) {
43  return plugins::ToDbModel(lockInfo, model::PublicKeyToAddress(lockInfo.Account, networkIdentifier));
44  }
45  };
46 }}}
MongoReceiptPluginFactory.h
catapult::mongo::plugins::MongoLockInfoCacheStorageTraits::MapToMongoId
static auto MapToMongoId(const KeyType &key)
Maps key to a mongo identifier.
Definition: MongoLockInfoCacheStorageTraits.h:37
catapult::mongo::plugins::MongoLockInfoCacheStorageTraits
Mongo lock info cache storage traits.
Definition: MongoLockInfoCacheStorageTraits.h:29
RegisterMongoSubsystem
PLUGIN_API void RegisterMongoSubsystem(catapult::mongo::MongoPluginManager &manager)
Entry point for registering a dynamic module with manager.
Definition: MongoHashLockPlugin.cpp:28
catapult::mongo::plugins::MongoLockInfoCacheStorageTraits::KeyType
typename TLockInfoTraits::KeyType KeyType
Definition: MongoLockInfoCacheStorageTraits.h:32
catapult::mongo::MongoPluginManager::addTransactionSupport
void addTransactionSupport(std::unique_ptr< MongoTransactionPlugin > &&pTransactionPlugin)
Adds support for a transaction described by pTransactionPlugin.
Definition: MongoPluginManager.h:53
catapult::mongo::MongoPluginManager::networkIdentifier
model::NetworkIdentifier networkIdentifier() const
Gets the network idenfifier.
Definition: MongoPluginManager.h:47
catapult::mongo::plugins::MongoLockInfoCacheStorageTraits::ModelType
typename TLockInfoTraits::ModelType ModelType
Definition: MongoLockInfoCacheStorageTraits.h:33
catapult::mongo::MongoPluginManager::addStorageSupport
void addStorageSupport(std::unique_ptr< TStorage > &&pStorage)
Adds support for an external cache storage described by pStorage.
Definition: MongoPluginManager.h:64
PLUGIN_API
#define PLUGIN_API
Definition: plugins.h:30
catapult::mongo::MongoPluginManager
A manager for registering mongo plugins.
Definition: MongoPluginManager.h:32
catapult::mongo::MongoPluginManager::mongoContext
MongoStorageContext & mongoContext() const
Gets the mongo storage context.
Definition: MongoPluginManager.h:42
catapult::mongo::plugins::MongoLockInfoCacheStorageTraits::MapToMongoDocument
static auto MapToMongoDocument(const ModelType &lockInfo, model::NetworkIdentifier networkIdentifier)
Maps lockInfo given network networkIdentifier to a mongo document.
Definition: MongoLockInfoCacheStorageTraits.h:42
catapult::mongo::plugins::MongoLockInfoCacheStorageTraits::CacheDeltaType
typename TLockInfoTraits::CacheDeltaType CacheDeltaType
Definition: MongoLockInfoCacheStorageTraits.h:31
Address.h
MongoHashLockInfoCacheStorage.h
catapult::mongo::plugins::CreateHashLockTransactionMongoPlugin
PLUGIN_API std::unique_ptr< MongoTransactionPlugin > CreateHashLockTransactionMongoPlugin()
Creates a mongo hash lock transaction plugin.
MongoPluginManager.h
catapult::model::PublicKeyToAddress
Address PublicKeyToAddress(const Key &publicKey, NetworkIdentifier networkIdentifier)
Creates an address from a public key (publicKey) for the network identified by networkIdentifier.
Definition: Address.cpp:50
catapult::model::NetworkIdentifier
NetworkIdentifier
Possible network identifiers.
Definition: NetworkInfo.h:45
catapult::mongo::plugins::ToDbModel
bsoncxx::document::value ToDbModel(const state::HashLockInfo &hashLockInfo, const Address &accountAddress)
Maps a hashLockInfo and accountAddress to the corresponding db model value.
Definition: HashLockInfoMapper.cpp:40
HashLockReceiptType.h
catapult::mongo::CreateBalanceChangeReceiptMongoPlugin
std::unique_ptr< MongoReceiptPlugin > CreateBalanceChangeReceiptMongoPlugin(model::ReceiptType type)
Creates a mongo balance change receipt plugin around type.
HashLockMapper.h
catapult::mongo::MongoPluginManager::addReceiptSupport
void addReceiptSupport(std::unique_ptr< MongoReceiptPlugin > &&pReceiptPlugin)
Adds support for a receipt described by pReceiptPlugin.
Definition: MongoPluginManager.h:58
catapult
Definition: AddressExtractionExtension.cpp:28
catapult::mongo::mappers::ToBinary
bsoncxx::types::b_binary ToBinary(const uint8_t *pData, size_t size)
Converts raw array (pData) of size elements into bson binary type.
Definition: MapperUtils.cpp:30
MongoCacheStorage.h