This repository has been archived by the owner on Apr 17, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 297
Query Error Responses #1770
Merged
Merged
Query Error Responses #1770
Changes from 4 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
8eaf120
Most features ase added
Akvinikym 27e06d0
Some minor fixes
Akvinikym 2d00e95
Added response for lacking permissions
Akvinikym a767d2c
Added response for noX
Akvinikym a03e75b
Gave some template parameters meaningful names
Akvinikym b15aad5
Other review issues
Akvinikym 66b83eb
Merge branch 'dev' into feature/qry-err-rsp
Akvinikym aeceef9
Review issues
Akvinikym 13ebd1d
More review issues
Akvinikym 55deb8f
Fix build
Akvinikym 583f651
Fix build
Akvinikym b65864a
Fixed forward
Akvinikym File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,6 @@ | |
#include "ametsuchi/impl/soci_utils.hpp" | ||
#include "ametsuchi/key_value_storage.hpp" | ||
#include "ametsuchi/storage.hpp" | ||
#include "builders/protobuf/builder_templates/query_response_template.hpp" | ||
#include "interfaces/commands/add_asset_quantity.hpp" | ||
#include "interfaces/commands/add_peer.hpp" | ||
#include "interfaces/commands/add_signatory.hpp" | ||
|
@@ -30,6 +29,7 @@ | |
#include "interfaces/commands/transfer_asset.hpp" | ||
#include "interfaces/common_objects/common_objects_factory.hpp" | ||
#include "interfaces/iroha_internal/block_json_converter.hpp" | ||
#include "interfaces/iroha_internal/query_response_factory.hpp" | ||
#include "interfaces/queries/blocks_query.hpp" | ||
#include "interfaces/queries/query.hpp" | ||
#include "interfaces/query_responses/query_response.hpp" | ||
|
@@ -38,11 +38,11 @@ | |
namespace iroha { | ||
namespace ametsuchi { | ||
|
||
using QueryResponseBuilderDone = | ||
shared_model::proto::TemplateQueryResponseBuilder<1>; | ||
using QueryErrorType = | ||
shared_model::interface::QueryResponseFactory::ErrorQueryType; | ||
|
||
class PostgresQueryExecutorVisitor | ||
: public boost::static_visitor<QueryResponseBuilderDone> { | ||
: public boost::static_visitor<QueryExecutorResult> { | ||
public: | ||
PostgresQueryExecutorVisitor( | ||
soci::session &sql, | ||
|
@@ -51,42 +51,46 @@ namespace iroha { | |
KeyValueStorage &block_store, | ||
std::shared_ptr<PendingTransactionStorage> pending_txs_storage, | ||
std::shared_ptr<shared_model::interface::BlockJsonConverter> | ||
converter); | ||
converter, | ||
std::shared_ptr<shared_model::interface::QueryResponseFactory> | ||
response_factory); | ||
|
||
void setCreatorId( | ||
const shared_model::interface::types::AccountIdType &creator_id); | ||
|
||
QueryResponseBuilderDone operator()( | ||
void setQueryHash(const shared_model::crypto::Hash &query_hash); | ||
|
||
QueryExecutorResult operator()( | ||
const shared_model::interface::GetAccount &q); | ||
|
||
QueryResponseBuilderDone operator()( | ||
QueryExecutorResult operator()( | ||
const shared_model::interface::GetSignatories &q); | ||
|
||
QueryResponseBuilderDone operator()( | ||
QueryExecutorResult operator()( | ||
const shared_model::interface::GetAccountTransactions &q); | ||
|
||
QueryResponseBuilderDone operator()( | ||
QueryExecutorResult operator()( | ||
const shared_model::interface::GetTransactions &q); | ||
|
||
QueryResponseBuilderDone operator()( | ||
QueryExecutorResult operator()( | ||
const shared_model::interface::GetAccountAssetTransactions &q); | ||
|
||
QueryResponseBuilderDone operator()( | ||
QueryExecutorResult operator()( | ||
const shared_model::interface::GetAccountAssets &q); | ||
|
||
QueryResponseBuilderDone operator()( | ||
QueryExecutorResult operator()( | ||
const shared_model::interface::GetAccountDetail &q); | ||
|
||
QueryResponseBuilderDone operator()( | ||
QueryExecutorResult operator()( | ||
const shared_model::interface::GetRoles &q); | ||
|
||
QueryResponseBuilderDone operator()( | ||
QueryExecutorResult operator()( | ||
const shared_model::interface::GetRolePermissions &q); | ||
|
||
QueryResponseBuilderDone operator()( | ||
QueryExecutorResult operator()( | ||
const shared_model::interface::GetAssetInfo &q); | ||
|
||
QueryResponseBuilderDone operator()( | ||
QueryExecutorResult operator()( | ||
const shared_model::interface::GetPendingTransactions &q); | ||
|
||
private: | ||
|
@@ -95,23 +99,34 @@ namespace iroha { | |
* predicate pred | ||
*/ | ||
template <typename RangeGen, typename Pred> | ||
auto getTransactionsFromBlock(uint64_t block_id, | ||
RangeGen &&range_gen, | ||
Pred &&pred); | ||
std::vector<std::unique_ptr<shared_model::interface::Transaction>> | ||
getTransactionsFromBlock(uint64_t block_id, | ||
RangeGen &&range_gen, | ||
Pred &&pred); | ||
|
||
/** | ||
* Execute query in F and return builder result from B | ||
* Execute query in F and return query response from B | ||
* Q is query tuple, P is permission tuple | ||
*/ | ||
template <typename Q, typename P, typename F, typename B> | ||
QueryResponseBuilderDone executeQuery(F &&f, B &&b); | ||
template <typename Q, | ||
typename P, | ||
typename F, | ||
typename B, | ||
typename ErrResponse> | ||
QueryExecutorResult executeQuery(F &&f, | ||
B &&b, | ||
ErrResponse &&err_response); | ||
|
||
soci::session &sql_; | ||
KeyValueStorage &block_store_; | ||
shared_model::interface::types::AccountIdType creator_id_; | ||
std::shared_ptr<shared_model::interface::CommonObjectsFactory> factory_; | ||
shared_model::crypto::Hash query_hash_; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. -> HashType? |
||
std::shared_ptr<shared_model::interface::CommonObjectsFactory> | ||
common_objects_factory_; | ||
std::shared_ptr<PendingTransactionStorage> pending_txs_storage_; | ||
std::shared_ptr<shared_model::interface::BlockJsonConverter> converter_; | ||
std::shared_ptr<shared_model::interface::QueryResponseFactory> | ||
query_response_factory_; | ||
logger::Logger log_; | ||
}; | ||
|
||
|
@@ -124,7 +139,9 @@ namespace iroha { | |
KeyValueStorage &block_store, | ||
std::shared_ptr<PendingTransactionStorage> pending_txs_storage, | ||
std::shared_ptr<shared_model::interface::BlockJsonConverter> | ||
converter); | ||
converter, | ||
std::shared_ptr<shared_model::interface::QueryResponseFactory> | ||
response_factory); | ||
|
||
QueryExecutorResult validateAndExecute( | ||
const shared_model::interface::Query &query) override; | ||
|
@@ -137,6 +154,8 @@ namespace iroha { | |
std::shared_ptr<shared_model::interface::CommonObjectsFactory> factory_; | ||
std::shared_ptr<PendingTransactionStorage> pending_txs_storage_; | ||
PostgresQueryExecutorVisitor visitor_; | ||
std::shared_ptr<shared_model::interface::QueryResponseFactory> | ||
query_response_factory_; | ||
logger::Logger log_; | ||
}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe name Q a QueryTuple instead? Same for the PermissionTuple
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am always for giving template parameters meaningful names :)