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

common objects factory for wsv query #1573

Merged
merged 20 commits into from
Jul 19, 2018

Conversation

nickaleks
Copy link
Contributor

Description of the Change

Replace builders in wsv_query with common objects factory

Benefits

No dependency on builders

Possible Drawbacks

none

Signed-off-by: Nikita Alekseev <[email protected]>

# Conflicts:
#	test/benchmark/CMakeLists.txt
#	test/benchmark/bm_proto_creation.cpp
This allows addition of validator in the future

Signed-off-by: Nikita Alekseev <[email protected]>

# Conflicts:
#	test/benchmark/CMakeLists.txt
#	test/benchmark/bm_proto_creation.cpp
This allows addition of validator in the future

Signed-off-by: Nikita Alekseev <[email protected]>

# Conflicts:
#	test/benchmark/CMakeLists.txt
#	test/benchmark/bm_proto_creation.cpp
Signed-off-by: Nikita Alekseev <[email protected]>

# Conflicts:
#	test/benchmark/CMakeLists.txt
#	test/benchmark/bm_proto_creation.cpp
Signed-off-by: Nikita Alekseev <[email protected]>

# Conflicts:
#	test/benchmark/CMakeLists.txt
#	test/benchmark/bm_proto_creation.cpp
Signed-off-by: Nikita Alekseev <[email protected]>

# Conflicts:
#	test/benchmark/CMakeLists.txt
#	test/benchmark/bm_proto_creation.cpp
Signed-off-by: Nikita Alekseev <[email protected]>

# Conflicts:
#	test/benchmark/CMakeLists.txt
#	test/benchmark/bm_proto_creation.cpp
Signed-off-by: Nikita Alekseev <[email protected]>

# Conflicts:
#	test/benchmark/CMakeLists.txt
#	test/benchmark/bm_proto_creation.cpp
Signed-off-by: Nikita Alekseev <[email protected]>

# Conflicts:
#	test/benchmark/CMakeLists.txt
#	test/benchmark/bm_proto_creation.cpp
Signed-off-by: Nikita Alekseev <[email protected]>

# Conflicts:
#	test/benchmark/CMakeLists.txt
#	test/benchmark/bm_proto_creation.cpp
Signed-off-by: Nikita Alekseev <[email protected]>

# Conflicts:
#	test/benchmark/CMakeLists.txt
#	test/benchmark/bm_proto_creation.cpp
Signed-off-by: Nikita Alekseev <[email protected]>
Signed-off-by: Nikita Alekseev <[email protected]>

# Conflicts:
#	irohad/ametsuchi/impl/mutable_storage_impl.cpp
#	irohad/ametsuchi/impl/mutable_storage_impl.hpp
#	irohad/ametsuchi/impl/postgres_block_query.cpp
#	irohad/ametsuchi/impl/postgres_wsv_common.hpp
#	irohad/ametsuchi/impl/postgres_wsv_query.cpp
#	irohad/ametsuchi/impl/postgres_wsv_query.hpp
#	irohad/ametsuchi/impl/storage_impl.cpp
#	irohad/ametsuchi/impl/storage_impl.hpp
#	irohad/ametsuchi/impl/temporary_wsv_impl.cpp
#	irohad/ametsuchi/impl/temporary_wsv_impl.hpp
#	test/module/irohad/ametsuchi/CMakeLists.txt
#	test/module/irohad/ametsuchi/ametsuchi_fixture.hpp
#	test/module/irohad/ametsuchi/wsv_query_command_test.cpp
#	test/module/shared_model/backend_proto/CMakeLists.txt
Signed-off-by: Nikita Alekseev <[email protected]>

# Conflicts:
#	irohad/ametsuchi/impl/mutable_storage_impl.cpp
#	irohad/ametsuchi/impl/mutable_storage_impl.hpp
#	irohad/ametsuchi/impl/postgres_block_query.cpp
#	irohad/ametsuchi/impl/postgres_wsv_common.hpp
#	irohad/ametsuchi/impl/postgres_wsv_query.cpp
#	irohad/ametsuchi/impl/postgres_wsv_query.hpp
#	irohad/ametsuchi/impl/storage_impl.cpp
#	irohad/ametsuchi/impl/storage_impl.hpp
#	irohad/ametsuchi/impl/temporary_wsv_impl.cpp
#	irohad/ametsuchi/impl/temporary_wsv_impl.hpp
#	test/module/irohad/ametsuchi/CMakeLists.txt
#	test/module/irohad/ametsuchi/ametsuchi_fixture.hpp
#	test/module/irohad/ametsuchi/wsv_query_command_test.cpp
#	test/module/shared_model/backend_proto/CMakeLists.txt
Signed-off-by: Nikita Alekseev <[email protected]>

# Conflicts:
#	test/module/shared_model/backend_proto/CMakeLists.txt
Signed-off-by: Nikita Alekseev <[email protected]>

# Conflicts:
#	test/module/shared_model/backend_proto/CMakeLists.txt
@nickaleks nickaleks force-pushed the feature/common_objects_factory_wsv_query branch from 89b23bf to 40d7996 Compare July 18, 2018 11:03
Signed-off-by: Nikita Alekseev <[email protected]>

# Conflicts:
#	test/module/shared_model/backend_proto/CMakeLists.txt
@nickaleks nickaleks force-pushed the feature/common_objects_factory_wsv_query branch from 40d7996 to c436031 Compare July 18, 2018 11:08
@nickaleks nickaleks requested a review from Akvinikym July 18, 2018 12:18
…ects_factory_wsv_query

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
@nickaleks nickaleks force-pushed the feature/common_objects_factory_wsv_query branch from cbd122a to 482e712 Compare July 18, 2018 12:18
@nickaleks nickaleks requested a review from vdrobnyi July 18, 2018 12:18
@@ -24,8 +24,12 @@
#include <boost/optional.hpp>
#include <cmath>
#include <shared_mutex>

#include <boost/optional.hpp>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it the same include at line 24?

#include "interfaces/common_objects/account_asset.hpp"
#include "interfaces/common_objects/asset.hpp"
#include "interfaces/common_objects/domain.hpp"
#include "interfaces/common_objects/signature.hpp"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe replace it with a forward declaration since it has only declarations?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also domain include seems to be duplication

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issues is with signature::SignedType. We cannot forward-declare inner classes.

storageResult.match(
auto new_storage_result =
StorageImpl::create(block_store_path, pgopt_, factory);
new_storage_result.match(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Top!

auto factory =
std::make_shared<shared_model::proto::ProtoCommonObjectsFactory<
shared_model::validation::FieldValidator>>();
auto storageResult = StorageImpl::create(block_store_dir_, pg_conn_, factory);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe create factory variable directly inside StorageImpl::create(..)? It's not used in code, and the space will be saved

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want to isolate protobuf specific implementations from the rest of the system.

@@ -78,6 +80,12 @@ namespace iroha {

std::shared_ptr<soci::session> sql;

std::shared_ptr<shared_model::proto::ProtoCommonObjectsFactory<
shared_model::validation::FieldValidator>>
factory =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not auto?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a class member

@@ -216,7 +216,7 @@ TEST_F(AmetsuchiTest, SampleTest) {
.build()}))
.height(2)
.prevHash(block1.hash())
.build();
.build();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty space?

@@ -34,6 +36,11 @@ class StorageInitTest : public ::testing::Test {
std::string pg_opt_without_dbname_;
std::string pgopt_;

std::shared_ptr<shared_model::proto::ProtoCommonObjectsFactory<
shared_model::validation::FieldValidator>>
factory = std::make_shared<shared_model::proto::ProtoCommonObjectsFactory<
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again not auto, is there a reason?

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
@@ -17,6 +17,7 @@

#include "ametsuchi/impl/postgres_wsv_query.hpp"
#include "backend/protobuf/permissions.hpp"
#include "common/result.hpp"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This include is presented in postgres_wsv_common.hpp. It is not necessary to have it here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better not to have transitive includes, so that if we change one header, we won't break stuff

@@ -284,16 +295,16 @@ namespace iroha {
(sql_.prepare << "SELECT public_key, address FROM peer");
std::vector<std::shared_ptr<shared_model::interface::Peer>> peers;

auto results = transform<
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is 'transform' from postgres_wsv_common.hpp called from somewhere? Can the method be removed?

@@ -13,6 +13,10 @@
#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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is the duplication of line 15

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
@nickaleks nickaleks force-pushed the feature/common_objects_factory_wsv_query branch from 8970d8f to be92c27 Compare July 19, 2018 11:06
@sorabot
Copy link

sorabot commented Jul 19, 2018

SonarQube analysis reported 7 issues

  1. MINOR postgres_block_index.hpp#L54: Unused private function: 'PostgresBlockIndex::indexAccountAssets' rule
  2. MINOR postgres_block_query.hpp#L78: Unused private function: 'PostgresBlockQuery::getBlockIds' rule
  3. MINOR postgres_block_query.hpp#L86: Unused private function: 'PostgresBlockQuery::getBlockId' rule
  4. MINOR postgres_block_query.hpp#L96: Unused private function: 'PostgresBlockQuery::callback' rule
  5. MINOR ametsuchi_fixture.hpp#L81: The class 'BlockQueryTransferTest' defines member variable with name 'sql' also defined in its parent class 'AmetsuchiTest'. rule
  6. MINOR ametsuchi_fixture.hpp#L81: The class 'WsvQueryCommandTest' defines member variable with name 'sql' also defined in its parent class 'AmetsuchiTest'. rule
  7. MINOR storage_init_test.cpp#L23: Variable 'pg_opt_without_dbname_' is assigned in constructor body. Consider performing initialization in initialization list. rule

@nickaleks nickaleks merged commit 4debf4e into develop Jul 19, 2018
@nickaleks nickaleks deleted the feature/common_objects_factory_wsv_query branch July 19, 2018 13:43
l4l pushed a commit that referenced this pull request Jul 25, 2018
l4l pushed a commit that referenced this pull request Jul 25, 2018
l4l pushed a commit that referenced this pull request Jul 25, 2018
l4l pushed a commit that referenced this pull request Jul 25, 2018
l4l pushed a commit that referenced this pull request Jul 25, 2018
l4l pushed a commit that referenced this pull request Jul 25, 2018
l4l pushed a commit that referenced this pull request Jul 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants