CatapultServer  v0.5.0.1 (Elephant)
AggregateTransaction.h
Go to the documentation of this file.
1 
21 #pragma once
22 #include "AggregateEntityType.h"
27 
28 namespace catapult { namespace model {
29 
30 #pragma pack(push, 1)
31 
34  public:
35  DEFINE_TRANSACTION_CONSTANTS(Entity_Type_Aggregate_Complete, 1)
36 
37  public:
40  uint32_t PayloadSize;
41 
42  // followed by sub-transaction data
43  // followed by cosignatures data
44  };
45 
47  struct AggregateTransaction : public TransactionContainer<AggregateTransactionHeader, EmbeddedTransaction> {
48  private:
49  template<typename T>
50  static auto* CosignaturesPtrT(T& transaction) {
51  return transaction.Size <= sizeof(T) + transaction.PayloadSize
52  ? nullptr
53  : transaction.ToBytePointer() + sizeof(T) + transaction.PayloadSize;
54  }
55 
56  template<typename T>
57  static size_t CosignaturesCountT(T& transaction) {
58  return transaction.Size <= sizeof(T) + transaction.PayloadSize
59  ? 0
60  : (transaction.Size - sizeof(T) - transaction.PayloadSize) / sizeof(Cosignature);
61  }
62 
63  public:
66  const Cosignature* CosignaturesPtr() const {
67  return reinterpret_cast<const Cosignature*>(CosignaturesPtrT(*this));
68  }
69 
73  return reinterpret_cast<Cosignature*>(CosignaturesPtrT(*this));
74  }
75 
78  size_t CosignaturesCount() const {
79  return CosignaturesCountT(*this);
80  }
81 
84  size_t CosignaturesCount() {
85  return CosignaturesCountT(*this);
86  }
87  };
88 
89 #pragma pack(pop)
90 
92  size_t GetTransactionPayloadSize(const AggregateTransactionHeader& header);
93 
96  bool IsSizeValid(const AggregateTransaction& aggregate, const TransactionRegistry& registry);
97 }}
catapult::model::TransactionContainer::Transactions
auto Transactions(EntityContainerErrorPolicy errorPolicy=EntityContainerErrorPolicy::Throw)
Definition: TransactionContainer.h:37
catapult::model::Cosignature
A cosignature.
Definition: Cosignature.h:29
CATAPULT_LOG
#define CATAPULT_LOG(SEV)
Writes a log entry to the default logger with SEV severity.
Definition: Logging.h:340
Transaction.h
AggregateTransaction.h
colorPrint.warning
def warning(*args)
Definition: colorPrint.py:10
catapult::model::AggregateTransactionHeader
Binary layout for an aggregate transaction header.
Definition: AggregateTransaction.h:33
catapult::model::GetTransactionPayloadSize
size_t GetTransactionPayloadSize(const AggregateTransactionHeader &header)
Gets the number of bytes containing transaction data according to header.
Definition: AggregateTransaction.cpp:25
catapult::model::AggregateTransaction::CosignaturesPtr
Cosignature * CosignaturesPtr()
Definition: AggregateTransaction.h:72
TransactionContainer.h
EntityType.h
catapult::model::AggregateTransaction::CosignaturesCountT
static size_t CosignaturesCountT(T &transaction)
Definition: AggregateTransaction.h:57
catapult::model::AggregateTransactionHeader::PayloadSize
uint32_t PayloadSize
Definition: AggregateTransaction.h:40
catapult::model::AggregateTransaction::CosignaturesPtrT
static auto * CosignaturesPtrT(T &transaction)
Definition: AggregateTransaction.h:50
catapult::model::IsSizeValid
bool IsSizeValid(const AggregateTransaction &aggregate, const TransactionRegistry &registry)
Definition: AggregateTransaction.cpp:38
catapult::model::TransactionContainer
Definition: TransactionContainer.h:34
DEFINE_TRANSACTION_CONSTANTS
#define DEFINE_TRANSACTION_CONSTANTS(TYPE, VERSION)
Defines constants for a transaction with TYPE and VERSION.
Definition: Transaction.h:50
AggregateEntityType.h
catapult::model::EntityContainerErrorPolicy::Suppress
Do not throw when an iteration error is encountered (but error flag will still be set).
catapult
Definition: AddressExtractionExtension.cpp:28
catapult::model::TransactionRegistry
A registry of transaction plugins.
Definition: TransactionPlugin.h:98
catapult::model::AggregateTransaction::CosignaturesCount
size_t CosignaturesCount()
Definition: AggregateTransaction.h:84
catapult::model::AggregateTransaction::CosignaturesPtr
const Cosignature * CosignaturesPtr() const
Definition: AggregateTransaction.h:66
catapult::model::AggregateTransaction::CosignaturesCount
size_t CosignaturesCount() const
Definition: AggregateTransaction.h:78
catapult::model::SizePrefixedEntity::Size
uint32_t Size
Entity size.
Definition: SizePrefixedEntity.h:33
catapult::model::AggregateTransaction
Binary layout for an aggregate transaction.
Definition: AggregateTransaction.h:47
catapult::model::Transaction
Binary layout for a transaction.
Definition: Transaction.h:32
Cosignature.h