Skip to content
This repository has been archived by the owner on Apr 17, 2019. It is now read-only.

Commit

Permalink
Fix review issues
Browse files Browse the repository at this point in the history
Signed-off-by: Nikita Alekseev <[email protected]>

# Conflicts:
#	shared_model/backend/protobuf/common_objects/proto_common_objects_factory.hpp
#	shared_model/interfaces/common_objects/common_objects_factory.hpp
#	test/module/shared_model/backend_proto/common_objects/proto_common_objects_factory_test.cpp
  • Loading branch information
nickaleks committed Jul 19, 2018
1 parent ad1ed98 commit 8970d8f
Show file tree
Hide file tree
Showing 11 changed files with 88 additions and 102 deletions.
5 changes: 5 additions & 0 deletions irohad/ametsuchi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,8 @@ target_link_libraries(ametsuchi
SOCI::core
SOCI::postgresql
)

target_compile_definitions(ametsuchi
PUBLIC SOCI_USE_BOOST HAVE_BOOST
)

2 changes: 1 addition & 1 deletion irohad/ametsuchi/impl/postgres_block_index.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include <boost/format.hpp>

#include "ametsuchi/impl/block_index.hpp"
#include "ametsuchi/impl/postgres_wsv_common.hpp"
#include "ametsuchi/impl/soci_utils.hpp"
#include "interfaces/transaction.hpp"
#include "logger/logger.hpp"

Expand Down
2 changes: 1 addition & 1 deletion irohad/ametsuchi/impl/postgres_block_query.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "ametsuchi/block_query.hpp"
#include "ametsuchi/impl/flat_file/flat_file.hpp"
#include "logger/logger.hpp"
#include "postgres_wsv_common.hpp"
#include "ametsuchi/impl/soci_utils.hpp"

namespace iroha {
namespace ametsuchi {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#ifndef IROHA_POSTGRES_ORDERING_SERVICE_PERSISTENT_STATE_HPP
#define IROHA_POSTGRES_ORDERING_SERVICE_PERSISTENT_STATE_HPP

#include "ametsuchi/impl/postgres_wsv_common.hpp"
#include "ametsuchi/impl/soci_utils.hpp"
#include "ametsuchi/ordering_service_persistent_state.hpp"
#include "common/result.hpp"
#include "logger/logger.hpp"
Expand Down
6 changes: 6 additions & 0 deletions irohad/ametsuchi/impl/postgres_wsv_command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,16 @@

#include "ametsuchi/impl/postgres_wsv_command.hpp"

#include <numeric>

#include <boost/format.hpp>

#include "backend/protobuf/permissions.hpp"
#include "interfaces/common_objects/account.hpp"
#include "interfaces/common_objects/account_asset.hpp"
#include "interfaces/common_objects/asset.hpp"
#include "interfaces/common_objects/domain.hpp"
#include "interfaces/common_objects/peer.hpp"

namespace iroha {
namespace ametsuchi {
Expand Down
2 changes: 1 addition & 1 deletion irohad/ametsuchi/impl/postgres_wsv_command.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#include "ametsuchi/wsv_command.hpp"

#include "ametsuchi/impl/postgres_wsv_common.hpp"
#include "ametsuchi/impl/soci_utils.hpp"

namespace iroha {
namespace ametsuchi {
Expand Down
94 changes: 0 additions & 94 deletions irohad/ametsuchi/impl/postgres_wsv_common.hpp

This file was deleted.

26 changes: 26 additions & 0 deletions irohad/ametsuchi/impl/postgres_wsv_query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,35 @@
*/

#include "ametsuchi/impl/postgres_wsv_query.hpp"

#include <soci/boost-tuple.h>

#include "ametsuchi/impl/soci_utils.hpp"
#include "backend/protobuf/permissions.hpp"
#include "common/result.hpp"

namespace {
/**
* Transforms result to optional
* value -> optional<value>
* error -> nullopt
* @tparam T type of object inside
* @param result BuilderResult
* @return optional<T>
*/
template <typename T>
boost::optional<std::shared_ptr<T>> fromResult(
shared_model::interface::CommonObjectsFactory::FactoryResult<
std::unique_ptr<T>> &&result) {
return result.match(
[](iroha::expected::Value<std::unique_ptr<T>> &v) {
return boost::make_optional(std::shared_ptr<T>(std::move(v.value)));
},
[](iroha::expected::Error<std::string>)
-> boost::optional<std::shared_ptr<T>> { return boost::none; });
}
} // namespace

namespace iroha {
namespace ametsuchi {

Expand Down
4 changes: 3 additions & 1 deletion irohad/ametsuchi/impl/postgres_wsv_query.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@

#include "ametsuchi/wsv_query.hpp"

#include <soci/soci.h>

#include "interfaces/common_objects/common_objects_factory.hpp"
#include "postgres_wsv_common.hpp"
#include "logger/logger.hpp"

namespace iroha {
namespace ametsuchi {
Expand Down
42 changes: 42 additions & 0 deletions irohad/ametsuchi/impl/soci_utils.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**
* Copyright Soramitsu Co., Ltd. 2018 All Rights Reserved.
* http://soramitsu.co.jp
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef IROHA_POSTGRES_WSV_COMMON_HPP
#define IROHA_POSTGRES_WSV_COMMON_HPP

#include <soci/soci.h>

namespace iroha {
namespace ametsuchi {
template <typename ParamType, typename Function>
inline void processSoci(soci::statement &st,
soci::indicator &ind,
ParamType &row,
Function f) {
while (st.fetch()) {
switch (ind) {
case soci::i_ok:
f(row);
case soci::i_null:
case soci::i_truncated:
break;
}
}
}
} // namespace ametsuchi
} // namespace iroha
#endif // IROHA_POSTGRES_WSV_COMMON_HPP
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@

#include "common/result.hpp"
#include "interfaces/common_objects/account.hpp"
#include "interfaces/common_objects/peer.hpp"
#include "interfaces/common_objects/types.hpp"
#include "interfaces/common_objects/domain.hpp"
#include "interfaces/common_objects/account_asset.hpp"
#include "interfaces/common_objects/asset.hpp"
#include "interfaces/common_objects/domain.hpp"
#include "interfaces/common_objects/peer.hpp"
#include "interfaces/common_objects/signature.hpp"
#include "interfaces/common_objects/types.hpp"

namespace shared_model {
namespace interface {
Expand Down

0 comments on commit 8970d8f

Please sign in to comment.