CatapultServer  v0.5.0.1 (Elephant)
TransactionChangeTracker.h
Go to the documentation of this file.
1 
21 #pragma once
22 #include "ContainerTypes.h"
23 #include "EntityInfo.h"
24 
25 namespace catapult { namespace model {
26 
29  public:
33  }
34 
38  }
39 
40  public:
42  void add(const TransactionInfo& transactionInfo) {
43  // if the info can be found in the set of deleted transactions, it means that
44  // it is currently in the collection so removing the info from the set means (re)adding it
45  auto iter = m_removedTransactionInfos.find(transactionInfo);
46  if (m_removedTransactionInfos.cend() != iter)
47  m_removedTransactionInfos.erase(iter);
48  else
49  m_addedTransactionInfos.emplace(transactionInfo.copy());
50  }
51 
53  void remove(const TransactionInfo& transactionInfo) {
54  // if the info can be found in the set of added transactions, simply remove it
55  // this only works because transactions are immutable (there are no upserts)
56  // so a newly saved transaction cannot already be in the database
57  auto iter = m_addedTransactionInfos.find(transactionInfo);
58  if (m_addedTransactionInfos.cend() != iter)
59  m_addedTransactionInfos.erase(iter);
60  else
61  m_removedTransactionInfos.emplace(transactionInfo.copy());
62  }
63 
65  void reset() {
68  }
69 
70  private:
73  };
74 }}
catapult::model::TransactionChangeTracker::reset
void reset()
Clears all added and removed transactions.
Definition: TransactionChangeTracker.h:65
catapult::model::TransactionChangeTracker
Tracks transaction changes and keeps track of net changes.
Definition: TransactionChangeTracker.h:28
catapult::model::TransactionChangeTracker::addedTransactionInfos
const TransactionInfosSet & addedTransactionInfos() const
Gets the infos of net added transactions.
Definition: TransactionChangeTracker.h:31
catapult::model::TransactionChangeTracker::m_addedTransactionInfos
TransactionInfosSet m_addedTransactionInfos
Definition: TransactionChangeTracker.h:71
catapult::model::TransactionChangeTracker::remove
void remove(const TransactionInfo &transactionInfo)
Marks transaction info (transactionInfo) as removed.
Definition: TransactionChangeTracker.h:53
catapult::model::TransactionInfo
A transaction and its associated metadata.
Definition: EntityInfo.h:104
EntityInfo.h
catapult::model::TransactionInfosSet
std::unordered_set< TransactionInfo, EntityInfoHasher< const Transaction >, EntityInfoComparer< const Transaction > > TransactionInfosSet
Unordered set of transaction infos.
Definition: ContainerTypes.h:50
ContainerTypes.h
catapult::model::TransactionChangeTracker::m_removedTransactionInfos
TransactionInfosSet m_removedTransactionInfos
Definition: TransactionChangeTracker.h:72
catapult
Definition: AddressExtractionExtension.cpp:28
catapult::model::TransactionChangeTracker::add
void add(const TransactionInfo &transactionInfo)
Marks transaction info (transactionInfo) as added.
Definition: TransactionChangeTracker.h:42
catapult::model::TransactionChangeTracker::removedTransactionInfos
const TransactionInfosSet & removedTransactionInfos() const
Gets the infos of net removed transactions.
Definition: TransactionChangeTracker.h:36
catapult::model::TransactionInfo::copy
TransactionInfo copy() const
Creates a (shallow) copy of this info.
Definition: EntityInfo.h:122