CatapultServer
v0.5.0.1 (Elephant)
|
Go to the documentation of this file.
26 namespace catapult {
namespace model {
38 template<TransactionPluginFactoryOptions Options>
42 template<
typename TEmbeddedTransaction,
typename TPublishEmbeddedFunc>
43 static std::unique_ptr<EmbeddedTransactionPlugin>
CreateEmbedded(TPublishEmbeddedFunc publishEmbeddedFunc) {
44 return std::make_unique<EmbeddedTransactionPluginT<TEmbeddedTransaction>>(publishEmbeddedFunc);
48 template<
typename TTransaction,
typename TEmbeddedTransaction,
typename TPublishFunc,
typename TPublishEmbeddedFunc>
49 static std::unique_ptr<TransactionPlugin>
Create(TPublishFunc publishFunc, TPublishEmbeddedFunc publishEmbeddedFunc) {
50 return std::make_unique<TransactionPluginT<TTransaction, TEmbeddedTransaction>>(publishFunc, publishEmbeddedFunc);
54 template<
typename TTransaction,
typename TDerivedTransaction,
typename TPlugin>
65 return TDerivedTransaction::Entity_Type;
69 auto version = TDerivedTransaction::Current_Version;
74 return TDerivedTransaction::CalculateRealSize(static_cast<const TDerivedTransaction&>(transaction));
79 m_publishFunc(static_cast<const TDerivedTransaction&>(transaction), sub);
86 template<
typename TEmbeddedTransaction>
93 template<
typename TPublishEmbeddedFunc>
103 template<
typename TTransaction,
typename TEmbeddedTransaction>
109 template<
typename TPublishFunc,
typename TPublishEmbeddedFunc>
122 return { reinterpret_cast<const uint8_t*>(&transaction) + headerSize, transaction.
Size - headerSize };
147 #define DEFINE_TRANSACTION_PLUGIN_FACTORY(NAME, OPTIONS, PUBLISH) \
148 std::unique_ptr<TransactionPlugin> Create##NAME##TransactionPlugin() { \
149 using Factory = TransactionPluginFactory<TransactionPluginFactoryOptions::OPTIONS>; \
150 return Factory::Create<NAME##Transaction, Embedded##NAME##Transaction>( \
151 PUBLISH<NAME##Transaction>, \
152 PUBLISH<Embedded##NAME##Transaction>); \
156 #define DEFINE_TRANSACTION_PLUGIN_FACTORY_WITH_CONFIG(NAME, OPTIONS, PUBLISH, CONFIG_TYPE) \
157 std::unique_ptr<TransactionPlugin> Create##NAME##TransactionPlugin(const CONFIG_TYPE& config) { \
158 using Factory = TransactionPluginFactory<TransactionPluginFactoryOptions::OPTIONS>; \
159 return Factory::Create<NAME##Transaction, Embedded##NAME##Transaction>( \
160 PUBLISH<NAME##Transaction>(config), \
161 PUBLISH<Embedded##NAME##Transaction>(config)); \
Transaction supports both top-level and embedding.
Definition: TransactionPluginFactory.h:104
void publish(const WeakEntityInfoT< Transaction > &transactionInfo, NotificationSubscriber &sub) const override
Sends all notifications from transactionInfo to sub.
Definition: TransactionPluginFactory.h:116
const EmbeddedTransactionPlugin & embeddedPlugin() const override
Gets the corresponding embedded plugin if supportsEmbedding() is true.
Definition: TransactionPluginFactory.h:137
A notification subscriber.
Definition: NotificationSubscriber.h:27
RawBuffer dataBuffer(const Transaction &transaction) const override
Extracts the primary data buffer from transaction that is used for signing and basic hashing.
Definition: TransactionPluginFactory.h:120
EntityType
Enumeration of entity types.
Definition: EntityType.h:43
bool supportsTopLevel() const override
true if this transaction type supports being embedded directly in blocks.
Definition: TransactionPluginFactory.h:129
consumer< const TTransaction &, NotificationSubscriber & > PublishFunc
Definition: TransactionPluginFactory.h:57
Represents a time duration.
Definition: TimeSpan.h:30
EntityType type() const override
Definition: TransactionPluginFactory.h:64
bool supportsEmbedding() const override
true if this transaction type supports being embedded in other transactions.
Definition: TransactionPluginFactory.h:133
Wrapper around a strongly typed entity and its associated metadata.
Definition: WeakEntityInfo.h:33
An embedded transaction plugin.
Definition: TransactionPlugin.h:68
TransactionPluginT(TPublishFunc publishFunc, TPublishEmbeddedFunc publishEmbeddedFunc)
Definition: TransactionPluginFactory.h:110
Definition: TransactionPluginFactory.h:87
static std::unique_ptr< EmbeddedTransactionPlugin > CreateEmbedded(TPublishEmbeddedFunc publishEmbeddedFunc)
Creates an embedded transaction plugin around publishEmbeddedFunc.
Definition: TransactionPluginFactory.h:43
static std::unique_ptr< TransactionPlugin > Create(TPublishFunc publishFunc, TPublishEmbeddedFunc publishEmbeddedFunc)
Creates a transaction plugin that supports embedding around publishFunc and publishEmbeddedFunc.
Definition: TransactionPluginFactory.h:49
constexpr const TEntity & entity() const
Gets the entity.
Definition: WeakEntityInfo.h:82
void publish(const EmbeddedTransaction &transaction, NotificationSubscriber &sub) const override
Sends all notifications from transaction to sub.
Definition: TransactionPluginFactory.h:98
std::unique_ptr< EmbeddedTransactionPlugin > m_pEmbeddedTransactionPlugin
Definition: TransactionPluginFactory.h:142
std::vector< RawBuffer > merkleSupplementaryBuffers(const Transaction &) const override
Definition: TransactionPluginFactory.h:125
Factory for creating transaction plugins.
Definition: TransactionPluginFactory.h:39
Transaction only supports embedding.
Binary layout for an embedded transaction (non-verifiable).
Definition: EmbeddedTransaction.h:38
Transaction dependent attributes.
Definition: TransactionPlugin.h:38
Definition: AddressExtractionExtension.cpp:28
TransactionAttributes attributes() const override
Definition: TransactionPluginFactory.h:68
BasicTransactionPluginT(const PublishFunc &publishFunc)
Definition: TransactionPluginFactory.h:60
Definition: TransactionPluginFactory.h:55
PublishFunc m_publishFunc
Definition: TransactionPluginFactory.h:83
void publishImpl(const TTransaction &transaction, NotificationSubscriber &sub) const
Definition: TransactionPluginFactory.h:78
uint64_t calculateRealSize(const TTransaction &transaction) const override
Definition: TransactionPluginFactory.h:73
EmbeddedTransactionPluginT(TPublishEmbeddedFunc publishEmbeddedFunc)
Definition: TransactionPluginFactory.h:94
TransactionPluginFactoryOptions
Transaction plugin factory options.
Definition: TransactionPluginFactory.h:29
std::function< void(TArgs...)> consumer
A consumer function.
Definition: functions.h:35
uint32_t Size
Entity size.
Definition: SizePrefixedEntity.h:33
BasicRawBuffer< const uint8_t > RawBuffer
A const binary buffer.
Definition: RawBuffer.h:62
Binary layout for a transaction.
Definition: Transaction.h:32