CatapultServer  v0.5.0.1 (Elephant)
PtUpdater.h
Go to the documentation of this file.
1 
21 #pragma once
23 #include "catapult/thread/Future.h"
24 #include <memory>
25 
26 namespace catapult {
27  namespace cache { class MemoryPtCacheProxy; }
28  namespace chain { class PtValidator; }
29  namespace model {
30  struct DetachedCosignature;
31  struct Transaction;
32  struct TransactionInfo;
33  }
34  namespace thread { class IoThreadPool; }
35 }
36 
37 namespace catapult { namespace chain {
38 
39  // region results
40 
44  enum class UpdateType {
46  New,
47 
49  Existing,
50 
52  Invalid
53  };
54 
57 
60  };
61 
65  Error,
66 
68  Ineligible,
69 
72 
74  Redundant,
75 
78 
81  };
82 
83  // endregion
84 
86  class PtUpdater {
87  public:
90 
91  public:
94  PtUpdater(
95  cache::MemoryPtCacheProxy& transactionsCache,
96  std::unique_ptr<const PtValidator>&& pValidator,
97  const CompletedTransactionSink& completedTransactionSink,
98  const FailedTransactionSink& failedTransactionSink,
99  const std::shared_ptr<thread::IoThreadPool>& pPool);
100 
102  ~PtUpdater();
103 
104  public:
107 
110 
111  private:
112  class Impl;
113  std::shared_ptr<Impl> m_pImpl; // shared_ptr to allow use of enable_shared_from_this
114  };
115 }}
FutureUtils.h
catapult::cache::MemoryCacheProxy::modifier
TCacheModifierProxy modifier() override
Definition: MemoryCacheProxy.h:58
catapult::chain::CosignatureUpdateResult::Added_Incomplete
Cosignature is added and did not complete the owning transaction.
catapult::chain::PtUpdater::Impl::handleComplete
void handleComplete(const model::WeakCosignedTransactionInfo &transactionInfo)
Definition: PtUpdater.cpp:379
CATAPULT_LOG
#define CATAPULT_LOG(SEV)
Writes a log entry to the default logger with SEV severity.
Definition: Logging.h:340
catapult::chain::CosignatureUpdateResult::Added_Complete
Cosignature is added and completed the owning transaction.
catapult::chain::TransactionUpdateResult::UpdateType::New
A new transaction.
catapult::chain::TransactionUpdateResult::NumCosignaturesAdded
size_t NumCosignaturesAdded
Number of cosignatures added.
Definition: PtUpdater.h:59
catapult::model::WeakCosignedTransactionInfo
Wrapper around a transaction and its cosignatures.
Definition: WeakCosignedTransactionInfo.h:29
catapult::cache::MemoryCacheProxy::view
auto view() const
Gets a read only view based on this cache.
Definition: MemoryCacheProxy.h:48
MemoryUtils.h
catapult::chain::PtUpdater::Impl::m_pPool
std::shared_ptr< thread::IoThreadPool > m_pPool
Definition: PtUpdater.cpp:393
AggregateTransaction.h
catapult::Hash256
utils::ByteArray< Hash256_Size, Hash256_tag > Hash256
Definition: src/catapult/types.h:47
catapult::chain::CheckEligibilityResult::CheckEligibilityResult
CheckEligibilityResult(CosignersValidationResult validationResult)
Definition: PtUpdater.cpp:84
catapult::chain::PtUpdater
Provides updating of a partial transactions cache.
Definition: PtUpdater.h:86
Parser.debug
def debug(*args)
Definition: Parser.py:46
catapult::chain::CosignatureUpdateResult::Error
Error occurred during processing of cosignature.
catapult::chain::PtUpdater::Impl::updateImpl
thread::future< TransactionUpdateResult > updateImpl(const TransactionUpdateContext &updateContext)
Definition: PtUpdater.cpp:180
catapult::chain::CheckEligibilityResult::isPurgeRequired
bool isPurgeRequired() const
Definition: PtUpdater.cpp:98
catapult::chain::CheckEligibilityResult
Definition: PtUpdater.cpp:77
catapult::chain::PtUpdater::Impl::update
thread::future< TransactionUpdateResult > update(const model::TransactionInfo &transactionInfo)
Definition: PtUpdater.cpp:145
catapult::model::WeakCosignedTransactionInfo::transaction
const Transaction & transaction() const
Gets the transaction.
Definition: WeakCosignedTransactionInfo.h:43
catapult::chain::FailedTransactionSink
consumer< const model::Transaction &, const Hash256 &, validators::ValidationResult > FailedTransactionSink
Indicates a transaction with the specified hash failed validation.
Definition: ChainFunctions.h:33
catapult::thread::IoThreadPool
Represents a thread pool that shares a single io context across multiple threads.
Definition: IoThreadPool.h:30
catapult::chain::PtUpdater::Impl::update
thread::future< TransactionUpdateResult > update(const DetachedCosignatures &cosignatures, TransactionUpdateResult::UpdateType updateType)
Definition: PtUpdater.cpp:236
catapult::chain::PtUpdater::CompletedTransactionSink
consumer< std::unique_ptr< model::Transaction > && > CompletedTransactionSink
Sink that is passed completed transactions.
Definition: PtUpdater.h:89
catapult::chain::StaleTransactionInfo
Definition: PtUpdater.cpp:72
catapult::chain::PtUpdater::Impl::m_pValidator
std::unique_ptr< const PtValidator > m_pValidator
Definition: PtUpdater.cpp:390
catapult::chain::TransactionUpdateResult::Type
UpdateType Type
Type of the update.
Definition: PtUpdater.h:56
catapult::chain::CheckEligibilityResult::staleTransactionInfo
const StaleTransactionInfo & staleTransactionInfo() const
Definition: PtUpdater.cpp:106
catapult::chain::PtUpdater::m_pImpl
std::shared_ptr< Impl > m_pImpl
Definition: PtUpdater.h:112
catapult::chain::PtUpdater::Impl::m_transactionsCache
cache::MemoryPtCacheProxy & m_transactionsCache
Definition: PtUpdater.cpp:389
catapult::cache::MemoryPtCacheProxy
A delegating proxy around a MemoryPtCache.
Definition: MemoryPtCache.h:97
catapult::chain::PtUpdater::Impl::addCosignature
CosignatureUpdateResult addCosignature(const model::DetachedCosignature &cosignature)
Definition: PtUpdater.cpp:257
catapult::chain::CheckEligibilityResult::setStaleTransactionInfo
void setStaleTransactionInfo(StaleTransactionInfo &&staleTransactionInfo)
Definition: PtUpdater.cpp:111
catapult::chain::PtUpdater::Impl
Definition: PtUpdater.cpp:121
catapult::chain::TransactionUpdateResult
Result of a transaction update.
Definition: PtUpdater.h:42
catapult::chain::PtUpdater::Impl::TransactionUpdateContext::pExtractedAddresses
std::shared_ptr< const model::UnresolvedAddressSet > pExtractedAddresses
Definition: PtUpdater.cpp:141
MemoryPtCache.h
catapult::model::TransactionInfo
A transaction and its associated metadata.
Definition: EntityInfo.h:104
catapult::chain::CosignatureUpdateResult::Redundant
Cosignature is redundant.
catapult::thread::when_all
future< std::vector< future< T > > > when_all(std::vector< future< T >> &&allFutures)
Returns a future that is signaled when all futures in allFutures complete.
Definition: FutureUtils.h:31
catapult::chain::PtUpdater::Impl::isValid
bool isValid(const model::Transaction &transaction, const Hash256 &aggregateHash) const
Definition: PtUpdater.cpp:290
catapult::cache::BasicTransactionsCacheModifierProxy::remove
TTransactionInfo remove(const Hash256 &hash)
Removes the transaction identified by hash from the cache.
Definition: BasicTransactionsCache.h:70
catapult::model::WeakEntityInfoT
Wrapper around a strongly typed entity and its associated metadata.
Definition: WeakEntityInfo.h:33
catapult::chain::CosignatureUpdateResult
CosignatureUpdateResult
Result of a cosignature update.
Definition: PtUpdater.h:63
catapult::partialtransaction::StitchAggregate
std::unique_ptr< model::Transaction > StitchAggregate(const model::WeakCosignedTransactionInfo &transactionInfo)
Stitches a weak cosigned transaction info into a full aggregate transaction.
Definition: PtUtils.cpp:27
catapult::chain::CheckEligibilityResult::m_validationResult
CosignersValidationResult m_validationResult
Definition: PtUpdater.cpp:117
HexFormatter.h
catapult::chain::CheckEligibilityResult::m_updateResult
CosignatureUpdateResult m_updateResult
Definition: PtUpdater.cpp:116
catapult::chain::PtUpdater::Impl::Impl
Impl(cache::MemoryPtCacheProxy &transactionsCache, std::unique_ptr< const PtValidator > &&pValidator, const CompletedTransactionSink &completedTransactionSink, const FailedTransactionSink &failedTransactionSink, const std::shared_ptr< thread::IoThreadPool > &pPool)
Definition: PtUpdater.cpp:123
catapult::chain::TransactionUpdateResult::UpdateType::Existing
An existing transaction.
catapult::chain::PtUpdater::Impl::remove
model::DetachedTransactionInfo remove(const Hash256 &aggregateHash)
Definition: PtUpdater.cpp:383
catapult::model::DetachedCosignature::ParentHash
Hash256 ParentHash
Hash of the corresponding parent.
Definition: Cosignature.h:48
catapult::chain::CheckEligibilityResult::m_pStaleTransactionInfo
std::unique_ptr< StaleTransactionInfo > m_pStaleTransactionInfo
Definition: PtUpdater.cpp:118
Signer.h
catapult::model::DetachedTransactionInfo::OptionalExtractedAddresses
std::shared_ptr< const UnresolvedAddressSet > OptionalExtractedAddresses
Extracted addresses (optional).
Definition: EntityInfo.h:100
catapult::chain::StaleTransactionInfo::AggregateHash
Hash256 AggregateHash
Definition: PtUpdater.cpp:73
catapult::model::Cosignature::Signer
Key Signer
Cosigner public key.
Definition: Cosignature.h:31
catapult::chain::StaleTransactionInfo::EligibleCosignatures
std::vector< model::Cosignature > EligibleCosignatures
Definition: PtUpdater.cpp:74
catapult::thread::future
Provides a way to access the result of an asynchronous operation.
Definition: Future.h:29
catapult::chain::TransactionUpdateResult::UpdateType::Invalid
An invalid transaction.
catapult::chain::PtUpdater::Impl::updateImpl
CosignatureUpdateResult updateImpl(const model::DetachedCosignature &cosignature)
Definition: PtUpdater.cpp:212
IoThreadPool.h
PtUtils.h
catapult::chain::CheckEligibilityResult::updateResult
CosignatureUpdateResult updateResult() const
Definition: PtUpdater.cpp:90
catapult::utils::KeySet
ArraySet< Key > KeySet
A key set.
Definition: ArraySet.h:64
catapult::chain::CheckEligibilityResult::CheckEligibilityResult
CheckEligibilityResult(CosignatureUpdateResult updateResult)
Definition: PtUpdater.cpp:79
catapult::chain::CosignersValidationResult::Missing
At least one cosigner is missing.
catapult::chain::PtUpdater::Impl::TransactionUpdateContext::AggregateHash
Hash256 AggregateHash
Definition: PtUpdater.cpp:139
catapult::chain::PtUpdater::Impl::m_completedTransactionSink
CompletedTransactionSink m_completedTransactionSink
Definition: PtUpdater.cpp:391
catapult::chain::PtValidator::Result
A validation result.
Definition: PtValidator.h:61
catapult::chain::CheckEligibilityResult::isEligibile
bool isEligibile() const
Definition: PtUpdater.cpp:94
catapult::chain::PtUpdater::Impl::TransactionUpdateContext
Definition: PtUpdater.cpp:137
catapult::thread::make_ready_future
future< T > make_ready_future(T &&value)
Produces a future that is ready immediately and holds the given value.
Definition: Future.h:126
catapult::chain::CosignersValidationResult::Success
All cosigners are eligible and sufficient.
catapult::chain::PtUpdater::Impl::validateCosigners
PtValidator::Result< CosignersValidationResult > validateCosigners(const model::WeakCosignedTransactionInfo &transactionInfo, const std::vector< model::Cosignature > &cosignatures) const
Definition: PtUpdater.cpp:369
catapult::chain::PtUpdater::Impl::checkEligibility
CheckEligibilityResult checkEligibility(const model::DetachedCosignature &cosignature) const
Definition: PtUpdater.cpp:302
catapult::chain::PtUpdater::PtUpdater
PtUpdater(cache::MemoryPtCacheProxy &transactionsCache, std::unique_ptr< const PtValidator > &&pValidator, const CompletedTransactionSink &completedTransactionSink, const FailedTransactionSink &failedTransactionSink, const std::shared_ptr< thread::IoThreadPool > &pPool)
Definition: PtUpdater.cpp:396
catapult::chain::CosignersValidationResult
CosignersValidationResult
Result of a partial transaction cosigners validation.
Definition: PtValidator.h:38
PtValidator.h
ChainFunctions.h
ArraySet.h
catapult::chain::PtUpdater::Impl::isComplete
bool isComplete(const model::WeakCosignedTransactionInfo &transactionInfo) const
Definition: PtUpdater.cpp:375
catapult::chain::PtUpdater::Impl::checkCompleteness
CosignatureUpdateResult checkCompleteness(const Hash256 &aggregateHash)
Definition: PtUpdater.cpp:268
CATAPULT_THROW_INVALID_ARGUMENT
#define CATAPULT_THROW_INVALID_ARGUMENT(MESSAGE)
Macro used to throw a catapult invalid argument.
Definition: exceptions.h:179
catapult::chain::TransactionUpdateResult::UpdateType
UpdateType
Possible update types.
Definition: PtUpdater.h:44
catapult::model::EntityInfo::pEntity
std::shared_ptr< TEntity > pEntity
Entity pointer.
Definition: EntityInfo.h:45
catapult
Definition: AddressExtractionExtension.cpp:28
catapult::chain::CheckEligibilityResult::isCacheStale
bool isCacheStale() const
Definition: PtUpdater.cpp:102
catapult::crypto::Verify
bool Verify(const Key &publicKey, const RawBuffer &dataBuffer, const Signature &signature)
Definition: Signer.cpp:136
Future.h
catapult::chain::PtUpdater::Impl::m_failedTransactionSink
FailedTransactionSink m_failedTransactionSink
Definition: PtUpdater.cpp:392
catapult::chain::PtUpdater::update
thread::future< TransactionUpdateResult > update(const model::TransactionInfo &transactionInfo)
Updates this cache by adding a new transaction info (transactionInfo).
Definition: PtUpdater.cpp:412
catapult::model::BasicEntityType::Transaction
Transaction type.
catapult::chain::CosignatureUpdateResult::Unverifiable
Cosignature is unverifiable.
catapult::utils::ByteArray< Hash256_Size, Hash256_tag >
catapult::chain::CosignersValidationResult::Failure
Transaction failed validation and should be rejected.
catapult::cache::PtCacheModifierProxy::add
model::DetachedTransactionInfo add(const Hash256 &parentHash, const Key &signer, const Signature &signature)
Adds a cosignature (composed of signer and signature) for a partial transaction with hash parentHash ...
Definition: PtCache.h:55
catapult::model::EntityInfo::EntityHash
Hash256 EntityHash
Entity hash.
Definition: EntityInfo.h:48
catapult::model::DetachedCosignature
A detached cosignature.
Definition: Cosignature.h:38
PtUpdater.h
catapult::chain::PtUpdater::Impl::update
thread::future< CosignatureUpdateResult > update(const model::DetachedCosignature &cosignature)
Definition: PtUpdater.cpp:199
catapult::chain::PtUpdater::Impl::refreshStaleCacheEntry
void refreshStaleCacheEntry(const StaleTransactionInfo &staleTransactionInfo)
Definition: PtUpdater.cpp:357
catapult::consumer
std::function< void(TArgs...)> consumer
A consumer function.
Definition: functions.h:35
catapult::chain::CosignatureUpdateResult::Ineligible
Cosignature is ineligible.
catapult::chain::PtUpdater::Impl::TransactionUpdateContext::Cosignatures
DetachedCosignatures Cosignatures
Definition: PtUpdater.cpp:140
catapult::chain::PtUpdater::Impl::TransactionUpdateContext::pAggregateTransaction
std::shared_ptr< const model::AggregateTransaction > pAggregateTransaction
Definition: PtUpdater.cpp:138
catapult::model::Cosignature::Signature
catapult::Signature Signature
Cosigner signature.
Definition: Cosignature.h:34
catapult::chain::PtUpdater::~PtUpdater
~PtUpdater()
Destroys the updater.
catapult::model::DetachedTransactionInfo
Definition: EntityInfo.h:77
catapult::model::Transaction
Binary layout for a transaction.
Definition: Transaction.h:32