Skip to content

Commit

Permalink
Add more verbose comments to TODO messages + tasks in jira (hyperledg…
Browse files Browse the repository at this point in the history
…er-iroha#941)

* Add todo with tasks

Signed-off-by: grimadas <[email protected]>

* Fix comment

Signed-off-by: grimadas <[email protected]>

* Apply clang

Signed-off-by: grimadas <[email protected]>
  • Loading branch information
grimadas authored and x3medima17 committed Mar 30, 2018
1 parent 4e40050 commit b7b2e9e
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 34 deletions.
56 changes: 33 additions & 23 deletions irohad/model/execution/impl/command_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,10 @@ namespace iroha {
const Command &command,
ametsuchi::WsvQuery &queries,
const std::string &creator_account_id) {
// TODO: no additional checks ?
return true;
}

// --------------------------|Revoke
// Permission|-----------------------------
// -----------|Revoke Permission|-----------
std::string RevokePermissionExecutor::commandName() const noexcept {
return "RevokePermission";
}
Expand Down Expand Up @@ -250,7 +248,6 @@ namespace iroha {
const Command &command,
ametsuchi::WsvQuery &queries,
const std::string &creator_account_id) {
// TODO: no checks needed ?
return true;
}

Expand All @@ -277,7 +274,8 @@ namespace iroha {
if (add_asset_quantity.amount.getPrecision() != precision) {
return makeExecutionResult(
(boost::format("precision mismatch: expected %d, but got %d")
% precision % add_asset_quantity.amount.getPrecision())
% precision
% add_asset_quantity.amount.getPrecision())
.str());
}

Expand Down Expand Up @@ -322,7 +320,9 @@ namespace iroha {
auto cmd_value = static_cast<const AddAssetQuantity &>(command);
// Check if creator has MoneyCreator permission.
// One can only add to his/her account
// TODO: In future: Separate money creation for distinct assets
// TODO: 03.02.2018 grimadas IR-935, Separate asset creation for distinct
// asset types, now: anyone having permission "can_add_asset_qty" can add
// any asset
return creator_account_id == cmd_value.account_id
and checkAccountRolePermission(
creator_account_id, queries, can_add_asset_qty);
Expand Down Expand Up @@ -360,14 +360,18 @@ namespace iroha {
if (subtract_asset_quantity.amount.getPrecision() != precision) {
return makeExecutionResult(
(boost::format("precision mismatch: expected %d, but got %d")
% precision % subtract_asset_quantity.amount.getPrecision())
% precision
% subtract_asset_quantity.amount.getPrecision())
.str());
}
auto account_asset = queries.getAccountAsset(
subtract_asset_quantity.account_id, subtract_asset_quantity.asset_id) | [&](auto &a) {
return boost::make_optional(
*std::unique_ptr<iroha::model::AccountAsset>(a->makeOldModel()));
};
auto account_asset =
queries.getAccountAsset(subtract_asset_quantity.account_id,
subtract_asset_quantity.asset_id)
| [&](auto &a) {
return boost::make_optional(
*std::unique_ptr<iroha::model::AccountAsset>(
a->makeOldModel()));
};
if (not account_asset) {
return makeExecutionResult((boost::format("account %s does not have %s")
% subtract_asset_quantity.account_id
Expand Down Expand Up @@ -502,7 +506,7 @@ namespace iroha {
(boost::format("Domain %s not found") % create_account.domain_id)
.str());
}
// TODO: remove insert signatory from here ?
// Account must have unique initial pubkey
auto result = commands.insertSignatory(create_account.pubkey) | [&] {
return commands.insertAccount(account);
} | [&] {
Expand Down Expand Up @@ -792,11 +796,14 @@ namespace iroha {
const std::string &creator_account_id) {
auto transfer_asset = static_cast<const TransferAsset &>(command);

auto src_account_asset = queries.getAccountAsset(
transfer_asset.src_account_id, transfer_asset.asset_id) | [](auto &a) {
return boost::make_optional(
*std::unique_ptr<iroha::model::AccountAsset>(a->makeOldModel()));
};
auto src_account_asset =
queries.getAccountAsset(transfer_asset.src_account_id,
transfer_asset.asset_id)
| [](auto &a) {
return boost::make_optional(
*std::unique_ptr<iroha::model::AccountAsset>(
a->makeOldModel()));
};
if (not src_account_asset) {
return makeExecutionResult((boost::format("asset %s is absent of %s")
% transfer_asset.asset_id
Expand All @@ -805,11 +812,14 @@ namespace iroha {
}

AccountAsset dest_AccountAsset;
auto dest_account_asset = queries.getAccountAsset(
transfer_asset.dest_account_id, transfer_asset.asset_id) | [](auto &a) {
return boost::make_optional(
*std::unique_ptr<iroha::model::AccountAsset>(a->makeOldModel()));
};
auto dest_account_asset =
queries.getAccountAsset(transfer_asset.dest_account_id,
transfer_asset.asset_id)
| [](auto &a) {
return boost::make_optional(
*std::unique_ptr<iroha::model::AccountAsset>(
a->makeOldModel()));
};
auto asset = queries.getAsset(transfer_asset.asset_id);
if (not asset) {
return makeExecutionResult((boost::format("asset %s is absent of %s")
Expand Down
22 changes: 11 additions & 11 deletions irohad/model/impl/query_execution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,25 +77,25 @@ bool hasQueryPermission(const std::string &creator,
}

bool QueryProcessingFactory::validate(const model::GetAssetInfo &query) {
// TODO: check signatures
// TODO: 03.02.2018 grimadas IR-851: check signatures
return checkAccountRolePermission(
query.creator_account_id, *_wsvQuery, can_read_assets);
}

bool QueryProcessingFactory::validate(const model::GetRoles &query) {
// TODO: check signatures
// TODO: 03.02.2018 grimadas IR-851: check signatures
return checkAccountRolePermission(
query.creator_account_id, *_wsvQuery, can_get_roles);
}

bool QueryProcessingFactory::validate(const model::GetRolePermissions &query) {
// TODO: check signatures
// TODO: 03.02.2018 grimadas IR-851: check signatures
return checkAccountRolePermission(
query.creator_account_id, *_wsvQuery, can_get_roles);
}

bool QueryProcessingFactory::validate(const model::GetAccount &query) {
// TODO: check signatures
// TODO: 03.02.2018 grimadas IR-851: check signatures
return hasQueryPermission(query.creator_account_id,
query.account_id,
*_wsvQuery,
Expand All @@ -105,7 +105,7 @@ bool QueryProcessingFactory::validate(const model::GetAccount &query) {
}

bool QueryProcessingFactory::validate(const model::GetSignatories &query) {
// TODO: check signatures
// TODO: 03.02.2018 grimadas IR-851: check signatures
return hasQueryPermission(query.creator_account_id,
query.account_id,
*_wsvQuery,
Expand All @@ -115,7 +115,7 @@ bool QueryProcessingFactory::validate(const model::GetSignatories &query) {
}

bool QueryProcessingFactory::validate(const model::GetAccountAssets &query) {
// TODO: check signatures
// TODO: 03.02.2018 grimadas IR-851: check signatures
return hasQueryPermission(query.creator_account_id,
query.account_id,
*_wsvQuery,
Expand All @@ -125,7 +125,7 @@ bool QueryProcessingFactory::validate(const model::GetAccountAssets &query) {
}

bool QueryProcessingFactory::validate(const model::GetAccountDetail &query) {
// TODO: check signatures
// TODO: 03.02.2018 grimadas IR-851: check signatures
return hasQueryPermission(query.creator_account_id,
query.account_id,
*_wsvQuery,
Expand All @@ -136,7 +136,7 @@ bool QueryProcessingFactory::validate(const model::GetAccountDetail &query) {

bool QueryProcessingFactory::validate(
const model::GetAccountTransactions &query) {
// TODO: check signatures
// TODO: 03.02.2018 grimadas IR-851: check signatures
return hasQueryPermission(query.creator_account_id,
query.account_id,
*_wsvQuery,
Expand All @@ -147,7 +147,7 @@ bool QueryProcessingFactory::validate(

bool QueryProcessingFactory::validate(
const model::GetAccountAssetTransactions &query) {
// TODO: check signatures
// TODO: 03.02.2018 grimadas IR-851: check signatures
return hasQueryPermission(query.creator_account_id,
query.account_id,
*_wsvQuery,
Expand All @@ -157,7 +157,7 @@ bool QueryProcessingFactory::validate(
}

bool QueryProcessingFactory::validate(const model::GetTransactions &query) {
// TODO: check signatures
// TODO: 03.02.2018 grimadas IR-851: check signatures
return checkAccountRolePermission(
query.creator_account_id, *_wsvQuery, can_get_my_txs)
or checkAccountRolePermission(
Expand Down Expand Up @@ -338,7 +338,7 @@ std::shared_ptr<QueryResponse> QueryProcessingFactory::executeGetSignatories(

std::shared_ptr<QueryResponse> QueryProcessingFactory::execute(
std::shared_ptr<const model::Query> query) {
// TODO 26/09/17 Nasrulin: change to handler map or/with templates #VARIANT
// TODO: 03.02.2018 grimadas IR-936 change to handler map or/with templates #VARIANT
if (instanceof <GetAccount>(query.get())) {
auto qry = std::static_pointer_cast<const GetAccount>(query);

Expand Down

0 comments on commit b7b2e9e

Please sign in to comment.