hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
transaction_status_builder.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_TRANSACTION_STATUS_BUILDER_HPP
7 #define IROHA_TRANSACTION_STATUS_BUILDER_HPP
8 
10 
11 namespace shared_model {
12  namespace builder {
13 
14  // TODO: kamilsa 09.02.2018 IR-1087 Improve transaction status builder, so
15  // that it is not allowed to set more than one status and transaction hash
16  // is set before build method is invoked
21  template <typename BuilderImpl>
23  public:
24  std::shared_ptr<shared_model::interface::TransactionResponse> build() {
25  return clone(builder_.build());
26  }
27 
29  TransactionStatusBuilder copy(*this);
30  copy.builder_ = this->builder_.statelessValidationSuccess();
31  return copy;
32  }
33 
35  TransactionStatusBuilder copy(*this);
36  copy.builder_ = this->builder_.statelessValidationFailed();
37  return copy;
38  }
39 
41  TransactionStatusBuilder copy(*this);
42  copy.builder_ = this->builder_.mstPending();
43  return copy;
44  }
45 
47  TransactionStatusBuilder copy(*this);
48  copy.builder_ = this->builder_.enoughSignaturesCollected();
49  return copy;
50  }
51 
53  TransactionStatusBuilder copy(*this);
54  copy.builder_ = this->builder_.statefulValidationSuccess();
55  return copy;
56  }
57 
59  TransactionStatusBuilder copy(*this);
60  copy.builder_ = this->builder_.statefulValidationFailed();
61  return copy;
62  }
63 
65  TransactionStatusBuilder copy(*this);
66  copy.builder_ = this->builder_.committed();
67  return copy;
68  }
69 
71  TransactionStatusBuilder copy(*this);
72  copy.builder_ = this->builder_.notReceived();
73  return copy;
74  }
75 
77  TransactionStatusBuilder copy(*this);
78  copy.builder_ = this->builder_.mstExpired();
79  return copy;
80  }
81 
83  TransactionStatusBuilder copy(*this);
84  copy.builder_ = this->builder_.txHash(hash);
85  return copy;
86  }
87 
89  const std::string &name) {
90  TransactionStatusBuilder copy(*this);
91  copy.builder_ = this->builder_.statelessErrorOrCmdName(name);
92  return copy;
93  }
94 
96  TransactionStatusBuilder copy(*this);
97  copy.builder_ = this->builder_.failedCmdIndex(index);
98  return copy;
99  }
100 
102  TransactionStatusBuilder copy(*this);
103  copy.builder_ = this->builder_.errorCode(code);
104  return copy;
105  }
106 
107  private:
108  BuilderImpl builder_;
109  };
110 
111  } // namespace builder
112 } // namespace shared_model
113 
114 #endif // IROHA_TRANSACTION_STATUS_BUILDER_HPP
Definition: hash.hpp:18
TransactionStatusBuilder statefulValidationSuccess()
Definition: transaction_status_builder.hpp:52
TransactionStatusBuilder failedCmdIndex(size_t index)
Definition: transaction_status_builder.hpp:95
std::unique_ptr< T > clone(const T &object)
Definition: cloneable.hpp:39
TransactionStatusBuilder statelessValidationSuccess()
Definition: transaction_status_builder.hpp:28
TransactionStatusBuilder statelessValidationFailed()
Definition: transaction_status_builder.hpp:34
string(REPLACE".""/"CMAKE_SWIG_OUTDIR ${SWIG_JAVA_PKG}) else() set(CMAKE_SWIG_FLAGS"") endif() myswig_add_library(irohajava LANGUAGE java SOURCES bindings.i) unset(CMAKE_SWIG_FLAGS) swig_link_libraries(irohajava $
Definition: CMakeLists.txt:54
name
Definition: setup.py:67
TransactionStatusBuilder txHash(const crypto::Hash &hash)
Definition: transaction_status_builder.hpp:82
TransactionStatusBuilder errorCode(uint32_t code)
Definition: transaction_status_builder.hpp:101
hash256_t hash(const T &pb)
Definition: pb_common.hpp:43
TransactionStatusBuilder committed()
Definition: transaction_status_builder.hpp:64
TransactionStatusBuilder notReceived()
Definition: transaction_status_builder.hpp:70
TransactionStatusBuilder enoughSignaturesCollected()
Definition: transaction_status_builder.hpp:46
TransactionStatusBuilder mstPending()
Definition: transaction_status_builder.hpp:40
TransactionStatusBuilder statelessErrorOrCmdName(const std::string &name)
Definition: transaction_status_builder.hpp:88
Definition: transaction_status_builder.hpp:22
Definition: command_executor.hpp:12
std::shared_ptr< shared_model::interface::TransactionResponse > build()
Definition: transaction_status_builder.hpp:24
TransactionStatusBuilder statefulValidationFailed()
Definition: transaction_status_builder.hpp:58
TransactionStatusBuilder mstExpired()
Definition: transaction_status_builder.hpp:76
#define DEPRECATED
Definition: swig_keyword_hider.hpp:15