hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
on_demand_ordering_service.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_ON_DEMAND_ORDERING_SERVICE_HPP
7 #define IROHA_ON_DEMAND_ORDERING_SERVICE_HPP
8 
9 #include <unordered_set>
10 
11 #include "consensus/round.hpp"
12 #include "cryptography/hash.hpp"
14 
15 namespace shared_model {
16  namespace interface {
17  class TransactionBatch;
18  class Proposal;
19  } // namespace interface
20 } // namespace shared_model
21 
22 namespace iroha {
23  namespace ordering {
24 
29  public:
30  virtual ~OnDemandOrderingService() = default;
31 
36 
39  size_t operator()(
40  const std::shared_ptr<shared_model::interface::TransactionBatch> &a)
41  const {
42  return hasher_(a->reducedHash());
43  }
44  };
45 
46  using BatchesSetType = std::unordered_set<
47  std::shared_ptr<shared_model::interface::TransactionBatch>,
50 
54  using TransactionBatchType =
55  std::shared_ptr<shared_model::interface::TransactionBatch>;
56 
60  using CollectionType = std::vector<TransactionBatchType>;
61 
66  virtual void onBatches(CollectionType batches) = 0;
67 
68  virtual std::optional<std::shared_ptr<const ProposalType>>
69  onRequestProposal(consensus::Round round) = 0;
70 
71  using HashesSetType =
72  std::unordered_set<shared_model::crypto::Hash,
74 
79  virtual void onCollaborationOutcome(consensus::Round round) = 0;
80 
85  virtual void onTxsCommitted(const HashesSetType &hashes) = 0;
86 
91  virtual void forCachedBatches(
92  std::function<void(const BatchesSetType &)> const &f) const = 0;
93 
94  virtual bool isEmptyBatchesCache() const = 0;
95 
96  virtual bool hasProposal(consensus::Round round) const = 0;
97 
98  virtual void processReceivedProposal(CollectionType batches) = 0;
99  };
100 
101  } // namespace ordering
102 } // namespace iroha
103 
104 #endif // IROHA_ON_DEMAND_ORDERING_SERVICE_HPP
Definition: hash.hpp:18
std::shared_ptr< shared_model::interface::TransactionBatch > TransactionBatchType
Definition: on_demand_ordering_service.hpp:55
Definition: transaction_batch.hpp:64
std::vector< TransactionBatchType > CollectionType
Definition: on_demand_ordering_service.hpp:60
Definition: on_demand_ordering_service.hpp:28
Definition: proposal.hpp:17
Definition: on_demand_ordering_service.hpp:37
std::unordered_set< shared_model::crypto::Hash, shared_model::crypto::Hash::Hasher > HashesSetType
Definition: on_demand_ordering_service.hpp:73
size_t operator()(const std::shared_ptr< shared_model::interface::TransactionBatch > &a) const
Definition: on_demand_ordering_service.hpp:39
Definition: block_query.hpp:15
std::unordered_set< std::shared_ptr< shared_model::interface::TransactionBatch >, BatchPointerHasher, shared_model::interface::BatchHashEquality > BatchesSetType
Definition: on_demand_ordering_service.hpp:49
shared_model::crypto::Hash::Hasher hasher_
Definition: on_demand_ordering_service.hpp:38
Definition: round.hpp:31
Definition: command_executor.hpp:13
Definition: hash.hpp:23