hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
transport_builder.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_TRANSPORT_BUILDER_HPP
7 #define IROHA_TRANSPORT_BUILDER_HPP
8 
9 #include "common/result.hpp"
11 
12 namespace shared_model {
13  namespace proto {
14 
21  template <typename T, typename SV>
22  class [[deprecated]] TransportBuilder {
23  TransportBuilder(const SV &validator) : stateless_validator_(validator) {}
24 
25  public:
26  TransportBuilder(std::shared_ptr<validation::ValidatorsConfig> config)
27  : TransportBuilder(SV(config)) {}
28 
33  iroha::expected::Result<T, std::string> build(
34  typename T::TransportType transport) {
35  auto result = T(transport);
36  auto answer = stateless_validator_.validate(result);
37  if (answer.hasErrors()) {
38  return iroha::expected::makeError(answer.reason());
39  }
40  return iroha::expected::makeValue(T(std::move(transport)));
41  }
42 
43  private:
44  SV stateless_validator_;
45  };
46 
47  } // namespace proto
48 } // namespace shared_model
49 #endif // IROHA_TRANSPORT_BUILDER_HPP
TransportBuilder(std::shared_ptr< validation::ValidatorsConfig > config)
Definition: transport_builder.hpp:26
iroha::expected::Result< T, std::string > build(typename T::TransportType transport)
Definition: transport_builder.hpp:33
Definition: transport_builder.hpp:22
Definition: command_executor.hpp:12