Skip to content

Commit

Permalink
Commands and queries for world state view
Browse files Browse the repository at this point in the history
  • Loading branch information
lebdron committed Jul 11, 2017
1 parent ac5d293 commit c46de07
Show file tree
Hide file tree
Showing 3 changed files with 116 additions and 81 deletions.
46 changes: 0 additions & 46 deletions irohad/ametsuchi/command_executor_stub.hpp

This file was deleted.

88 changes: 88 additions & 0 deletions irohad/ametsuchi/wsv_command.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/**
* Copyright Soramitsu Co., Ltd. 2017 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_WSV_COMMAND_HPP
#define IROHA_WSV_COMMAND_HPP

namespace iroha {
namespace ametsuchi {

/**
* Commands for modifying world state view
*/
class WsvCommand {
public:
virtual ~WsvCommand() = 0;

/**
* Update or insert account
* @param account
* @return true if no error occurred, false otherwise
*/
virtual bool upsertAccount(const model::Account &account) = 0;

/**
* Insert asset
* @param asset
* @return
*/
virtual bool insertAsset(const model::Asset &asset) = 0;

/**
* Update or insert wallet
* @param wallet
* @return
*/
virtual bool upsertWallet(const model::Wallet &wallet) = 0;

/**
* Insert signatory
* @param master_key
* @param signatory
* @return
*/
virtual bool insertSignatory(const ed25519::pubkey_t master_key,
const ed25519::pubkey_t signatory) = 0;

/**
* Delete signatory
* @param master_key
* @param signatory
* @return
*/
virtual bool deleteSignatory(const ed25519::pubkey_t master_key,
const ed25519::pubkey_t signatory) = 0;

/**
* Update or insert peer
* @param peer
* @return
*/
virtual bool upsertPeer(const model::Peer &peer) = 0;

/**
* Delete peer
* @param peer
* @return
*/
virtual bool deletePeer(const model::Peer &peer) = 0;
};

} // namespace ametsuchi
} // namespace iroha

#endif // IROHA_WSV_COMMAND_HPP
63 changes: 28 additions & 35 deletions irohad/ametsuchi/wsv_query.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,72 +15,65 @@
* limitations under the License.
*/

#ifndef IROHA_WSVQUERY_HPP
#define IROHA_WSVQUERY_HPP
#ifndef IROHA_WSV_QUERY_HPP
#define IROHA_WSV_QUERY_HPP

#include <common/types.hpp>
#include <model/model.hpp>
#include <string>
#include <vector>

namespace iroha {

namespace ametsuchi {

/**
* Public interface for world state view queries
*/
class WsvQuery {
public:
/**
* Get peer by it pub key
* @param pub_key
* @return Peer Model
*/
virtual iroha::model::Peer get_peer(
iroha::ed25519::pubkey_t pub_key) = 0;
virtual ~WsvQuery() = default;

/**
* Get account by it's first public key.
* @param pub_key
* @return Model Account
* Get account by user master key
* @param master_key
* @return
*/
virtual model::Account get_account(
ed25519::pubkey_t pub_key) = 0;
virtual model::Account getAccount(
const ed25519::pubkey_t &master_key) = 0;

/**
* Get asset by full name. For example USD#soramitsu.co.jp
* @param full_name of an asset (name#domain)
* @return Model Asset
* Get signatories of account by user master key
* @param master_key
* @return
*/
virtual model::Asset get_asset(std::string asset_full_name) = 0;
virtual std::vector<ed25519::pubkey_t> getSignatories(
const ed25519::pubkey_t &master_key) = 0;

/**
* Get wallet by wallet_id
* @param wallet_id
* @return Model Wallet
* Get asset by its name
* @param asset_id
* @return
*/
virtual model::Wallet get_wallet(std::string wallet_id) = 0;
virtual model::Asset getAsset(const std::string &asset_id) = 0;

/**
* Get all wallets of a account.
* @param pub_key of a account
* @return vector of Model Wallet
* Get wallet of user
* @param master_key
* @param asset_id
* @return
*/
virtual std::vector<model::Wallet> get_account_wallets(
ed25519::pubkey_t pub_key) = 0;
virtual model::Wallet getWallet(const ed25519::pubkey_t &master_key,
const std::string &asset_id) = 0;

/**
* Get all asset of a domain.
* @param full_name of a domain
* @return vector of Model Asset
* Get peer by given IP address
* @param address
* @return
*/
virtual std::vector<model::Asset> get_domain_assets(
std::string domain_full_name) = 0;
virtual model::Peer getPeer(const std::string &address) = 0;
};

} // namespace ametsuchi

} // namespace iroha

#endif // IROHA_WSVQUERY_HPP
#endif // IROHA_WSV_QUERY_HPP

0 comments on commit c46de07

Please sign in to comment.