Skip to content

Commit

Permalink
Fix review:
Browse files Browse the repository at this point in the history
simplify ProtoCommandVariantType
fix wrongly placed includes
change for_each to accumulate in role_permissions_

Signed-off-by: kamilsa <[email protected]>
  • Loading branch information
kamilsa authored and lebdron committed Dec 19, 2017
1 parent f81a13b commit c4dada6
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 27 deletions.
30 changes: 15 additions & 15 deletions shared_model/backend/protobuf/commands/proto_command.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ namespace shared_model {
Command> {
private:
/// polymorphic wrapper type shortcut
template <typename Value>
using w = detail::PolymorphicWrapper<Value>;
template <typename... Value>
using wrap = boost::variant<detail::PolymorphicWrapper<Value>...>;

/// lazy variant shortcut
template <typename T>
Expand All @@ -64,19 +64,19 @@ namespace shared_model {

public:
/// type of proto variant
using ProtoCommandVariantType = boost::variant<w<AddAssetQuantity>,
w<AddPeer>,
w<AddSignatory>,
w<AppendRole>,
w<CreateAccount>,
w<CreateAsset>,
w<CreateDomain>,
w<CreateRole>,
w<GrantPermission>,
w<RemoveSignatory>,
w<RevokePermission>,
w<SetQuorum>,
w<TransferAsset>>;
using ProtoCommandVariantType = wrap<AddAssetQuantity,
AddPeer,
AddSignatory,
AppendRole,
CreateAccount,
CreateAsset,
CreateDomain,
CreateRole,
GrantPermission,
RemoveSignatory,
RevokePermission,
SetQuorum,
TransferAsset>;

/// list of types in proto variant
using ProtoCommandListType = ProtoCommandVariantType::types;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
* limitations under the License.
*/

#include "interfaces/commands/create_asset.hpp"

#ifndef IROHA_PROTO_CREATE_ASSET_HPP
#define IROHA_PROTO_CREATE_ASSET_HPP

#include "interfaces/commands/create_asset.hpp"

namespace shared_model {
namespace proto {

Expand Down
18 changes: 9 additions & 9 deletions shared_model/backend/protobuf/commands/proto_create_role.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
* limitations under the License.
*/

#include "interfaces/commands/create_role.hpp"

#ifndef IROHA_PROTO_CREATE_ROLE_HPP
#define IROHA_PROTO_CREATE_ROLE_HPP

#include "interfaces/commands/create_role.hpp"
#include <boost/range/numeric.hpp>

namespace shared_model {
namespace proto {
class CreateRole final : public CopyableProto<interface::CreateRole,
Expand All @@ -32,16 +34,14 @@ namespace shared_model {
create_role_(detail::makeReferenceGenerator(
proto_, &iroha::protocol::Command::create_role)),
role_permissions_([this] {
std::set<std::string> perms;

std::for_each(
create_role_->permissions().begin(),
create_role_->permissions().end(),
[&perms](auto perm) {
perms.insert(iroha::protocol::RolePermission_Name(
return boost::accumulate(
create_role_->permissions(),
PermissionsType{},
[](auto &&acc, const auto &perm) {
acc.insert(iroha::protocol::RolePermission_Name(
static_cast<iroha::protocol::RolePermission>(perm)));
return std::forward<decltype(acc)>(acc);
});
return perms;
}) {}

CreateRole(const CreateRole &o) : CreateRole(o.proto_) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
* limitations under the License.
*/

#include "interfaces/commands/remove_signatory.hpp"

#ifndef IROHA_PROTO_REMOVE_SIGNATORY_HPP
#define IROHA_PROTO_REMOVE_SIGNATORY_HPP

#include "interfaces/commands/remove_signatory.hpp"

namespace shared_model {
namespace proto {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#ifndef IROHA_PROTO_REVOKE_PERMISSION_HPP
#define IROHA_PROTO_REVOKE_PERMISSION_HPP

#include "interfaces/commands/revoke_permission.hpp"

namespace shared_model {
namespace proto {
class RevokePermission final
Expand Down
2 changes: 1 addition & 1 deletion shared_model/cryptography/blob.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ namespace shared_model {
virtual const std::string &blob() const { return blob_; }

/**
* @return provides human-readable representation of blob
* @return provides human-readable representation of blob without leading 0x
*/
virtual const std::string &hex() const { return hex_; }

Expand Down

0 comments on commit c4dada6

Please sign in to comment.